Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RabbitMQ] bytecode instrumentation for versions 6.*.* - initial #3533

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell/other.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ PROCESSRUNTIME
proto
protobuf
protos
RABBITMQ
Serilog
spdlog
SQLCLIENT
Expand Down
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h
### Added

- Support for Operating System resource detector.
- Support for [RabbitMQ.Client](https://www.nuget.org/packages/RabbitMQ.Client/)
traces instrumentation for versions `6.0.0`-`6.*.*`
- Added support for OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER, OTEL_LOGS_EXPORTER
to handle comma-separated list.
- The environment variables `OTEL_TRACES_EXPORTER`, `OTEL_METRICS_EXPORTER`,
and `OTEL_LOGS_EXPORTER` now support configuring console exporters for traces,
metrics, and logs, respectively.
- Environment variables `OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED`,
`OTEL_DOTNET_AUTO_METRICS_CONSOLE_EXPORTER_ENABLED`, and
`OTEL_DOTNET_AUTO_LOGS_CONSOLE_EXPORTER_ENABLED` are now marked as deprecated.
- Support signal specific OTLP exporter variables (See [docs](/docs/config.md#otlp)):
- `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`,
- `OTEL_EXPORTER_OTLP_TRACES_HEADERS`,
Expand Down Expand Up @@ -54,6 +53,10 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h

### Deprecated

- Environment variables `OTEL_DOTNET_AUTO_TRACES_CONSOLE_EXPORTER_ENABLED`,
`OTEL_DOTNET_AUTO_METRICS_CONSOLE_EXPORTER_ENABLED`, and
`OTEL_DOTNET_AUTO_LOGS_CONSOLE_EXPORTER_ENABLED` are now marked as deprecated.

### Removed

- Support for macOS Big Sur 11 x64.
Expand Down
19 changes: 19 additions & 0 deletions OpenTelemetry.AutoInstrumentation.sln
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestApplication.OracleMda.C
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "getting-started-dotnet-monitor-logs", "next-gen\docs\getting-started-dotnet-monitor-logs\getting-started-dotnet-monitor-logs.csproj", "{959764E7-5A0C-4511-8004-48DE6B10F499}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestApplication.RabbitMq", "test\test-applications\integrations\TestApplication.RabbitMq\TestApplication.RabbitMq.csproj", "{91D883EC-069E-46BC-B6F7-67C94299851E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -1459,6 +1461,22 @@ Global
{959764E7-5A0C-4511-8004-48DE6B10F499}.Release|x64.Build.0 = Release|Any CPU
{959764E7-5A0C-4511-8004-48DE6B10F499}.Release|x86.ActiveCfg = Release|Any CPU
{959764E7-5A0C-4511-8004-48DE6B10F499}.Release|x86.Build.0 = Release|Any CPU
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|Any CPU.ActiveCfg = Debug|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|Any CPU.Build.0 = Debug|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|ARM64.ActiveCfg = Debug|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|ARM64.Build.0 = Debug|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|x64.ActiveCfg = Debug|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|x64.Build.0 = Debug|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|x86.ActiveCfg = Debug|x86
{91D883EC-069E-46BC-B6F7-67C94299851E}.Debug|x86.Build.0 = Debug|x86
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|Any CPU.ActiveCfg = Release|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|Any CPU.Build.0 = Release|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|ARM64.ActiveCfg = Release|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|ARM64.Build.0 = Release|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|x64.ActiveCfg = Release|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|x64.Build.0 = Release|x64
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|x86.ActiveCfg = Release|x86
{91D883EC-069E-46BC-B6F7-67C94299851E}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1545,6 +1563,7 @@ Global
{022A03CE-DD7A-4326-847E-3B750E660845} = {3F051815-8E0D-4356-BC36-55CA642DDF18}
{21A915DF-8B9E-4CE8-84DA-1057CDCE117E} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
{959764E7-5A0C-4511-8004-48DE6B10F499} = {3F051815-8E0D-4356-BC36-55CA642DDF18}
{91D883EC-069E-46BC-B6F7-67C94299851E} = {E409ADD3-9574-465C-AB09-4324D205CC7C}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {160A1D00-1F5B-40F8-A155-621B4459D78F}
Expand Down
8 changes: 8 additions & 0 deletions build/LibraryVersions.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,5 +181,13 @@ public static partial class LibraryVersion
new("2.4.0"),
}
},
{
"TestApplication.RabbitMq",
new List<PackageBuildInfo>
{
new("6.0.0"),
new("6.8.1"),
}
},
};
}
1 change: 1 addition & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ due to lack of stable semantic convention.
| `NPGSQL` | [Npgsql](https://www.nuget.org/packages/Npgsql) | ≥6.0.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `NSERVICEBUS` | [NServiceBus](https://www.nuget.org/packages/NServiceBus) | ≥8.0.0 & < 10.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `ORACLEMDA` | [Oracle.ManagedDataAccess.Core](https://www.nuget.org/packages/Oracle.ManagedDataAccess.Core) and [Oracle.ManagedDataAccess](https://www.nuget.org/packages/Oracle.ManagedDataAccess) **Not supported on ARM64** | ≥23.4.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `RABBITMQ` | [RabbitMQ.Client](https://www.nuget.org/packages/RabbitMQ.Client/) | ≥6.0.0 & < 7.0.0 | bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `QUARTZ` | [Quartz](https://www.nuget.org/packages/Quartz) **Not supported on .NET Framework 4.7.1 and older** | ≥3.4.0 | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `SQLCLIENT` | [Microsoft.Data.SqlClient](https://www.nuget.org/packages/Microsoft.Data.SqlClient), [System.Data.SqlClient](https://www.nuget.org/packages/System.Data.SqlClient) and `System.Data` (shipped with .NET Framework) | * \[6\] | source | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `STACKEXCHANGEREDIS` | [StackExchange.Redis](https://www.nuget.org/packages/StackExchange.Redis) **Not supported on .NET Framework** | ≥2.6.122 & < 3.0.0 | source & bytecode | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.AsyncEventingBasicConsumerIntegration
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.EventingBasicConsumerIntegration
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBaseBasicGetIntegration
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBasicPublishIntegration
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.AsyncEventingBasicConsumerIntegration
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.EventingBasicConsumerIntegration
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBaseBasicGetIntegration
OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBasicPublishIntegration
Original file line number Diff line number Diff line change
Expand Up @@ -127,5 +127,10 @@ internal enum TracerInstrumentation
/// <summary>
/// Oracle Managed Data Access (Core) instrumentation
/// </summary>
OracleMda = 21
OracleMda = 21,

/// <summary>
/// RabbitMQ instrumentation
/// </summary>
RabbitMq = 22
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static partial class InstrumentationDefinitions

private static NativeCallTargetDefinition[] GetDefinitionsArray()
{
var nativeCallTargetDefinitions = new List<NativeCallTargetDefinition>(16);
var nativeCallTargetDefinitions = new List<NativeCallTargetDefinition>(20);
// Traces
var tracerSettings = Instrumentation.TracerSettings.Value;
if (tracerSettings.TracesEnabled)
Expand Down Expand Up @@ -54,6 +54,15 @@ private static NativeCallTargetDefinition[] GetDefinitionsArray()
nativeCallTargetDefinitions.Add(new("NServiceBus.Core", "NServiceBus.EndpointConfiguration", ".ctor", new[] {"System.Void", "System.String"}, 8, 0, 0, 8, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.NServiceBus.EndpointConfigurationIntegration"));
}

// RabbitMq
if (tracerSettings.EnabledInstrumentations.Contains(TracerInstrumentation.RabbitMq))
{
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Events.AsyncEventingBasicConsumer", "HandleBasicDeliver", new[] {"System.Threading.Tasks.Task", "System.String", "System.UInt64", "System.Boolean", "System.String", "System.String", "RabbitMQ.Client.IBasicProperties", "System.ReadOnlyMemory`1[System.Byte]"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.AsyncEventingBasicConsumerIntegration"));
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Events.EventingBasicConsumer", "HandleBasicDeliver", new[] {"System.Void", "System.String", "System.UInt64", "System.Boolean", "System.String", "System.String", "RabbitMQ.Client.IBasicProperties", "System.ReadOnlyMemory`1[System.Byte]"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.EventingBasicConsumerIntegration"));
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Impl.ModelBase", "BasicGet", new[] {"RabbitMQ.Client.BasicGetResult", "System.String", "System.Boolean"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBaseBasicGetIntegration"));
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Framing.Impl.Model", "_Private_BasicPublish", new[] {"System.Void", "System.String", "System.String", "System.Boolean", "RabbitMQ.Client.IBasicProperties", "System.ReadOnlyMemory`1[System.Byte]"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBasicPublishIntegration"));
}

// WcfClient
if (tracerSettings.EnabledInstrumentations.Contains(TracerInstrumentation.WcfClient))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal static partial class InstrumentationDefinitions

private static NativeCallTargetDefinition[] GetDefinitionsArray()
{
var nativeCallTargetDefinitions = new List<NativeCallTargetDefinition>(19);
var nativeCallTargetDefinitions = new List<NativeCallTargetDefinition>(23);
// Traces
var tracerSettings = Instrumentation.TracerSettings.Value;
if (tracerSettings.TracesEnabled)
Expand Down Expand Up @@ -48,6 +48,15 @@ private static NativeCallTargetDefinition[] GetDefinitionsArray()
nativeCallTargetDefinitions.Add(new("NServiceBus.Core", "NServiceBus.EndpointConfiguration", ".ctor", new[] {"System.Void", "System.String"}, 8, 0, 0, 9, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.NServiceBus.EndpointConfigurationIntegration"));
}

// RabbitMq
if (tracerSettings.EnabledInstrumentations.Contains(TracerInstrumentation.RabbitMq))
{
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Events.AsyncEventingBasicConsumer", "HandleBasicDeliver", new[] {"System.Threading.Tasks.Task", "System.String", "System.UInt64", "System.Boolean", "System.String", "System.String", "RabbitMQ.Client.IBasicProperties", "System.ReadOnlyMemory`1[System.Byte]"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.AsyncEventingBasicConsumerIntegration"));
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Events.EventingBasicConsumer", "HandleBasicDeliver", new[] {"System.Void", "System.String", "System.UInt64", "System.Boolean", "System.String", "System.String", "RabbitMQ.Client.IBasicProperties", "System.ReadOnlyMemory`1[System.Byte]"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.EventingBasicConsumerIntegration"));
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Impl.ModelBase", "BasicGet", new[] {"RabbitMQ.Client.BasicGetResult", "System.String", "System.Boolean"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBaseBasicGetIntegration"));
nativeCallTargetDefinitions.Add(new("RabbitMQ.Client", "RabbitMQ.Client.Framing.Impl.Model", "_Private_BasicPublish", new[] {"System.Void", "System.String", "System.String", "System.Boolean", "RabbitMQ.Client.IBasicProperties", "System.ReadOnlyMemory`1[System.Byte]"}, 6, 0, 0, 6, 65535, 65535, AssemblyFullName, "OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.Integrations.ModelBasicPublishIntegration"));
}

// StackExchangeRedis
if (tracerSettings.EnabledInstrumentations.Contains(TracerInstrumentation.StackExchangeRedis))
{
Expand Down
2 changes: 2 additions & 0 deletions src/OpenTelemetry.AutoInstrumentation/Instrumentation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,8 @@ private static void AddLazilyLoadedTraceInstrumentations(LazyInstrumentationLoad
break;
case TracerInstrumentation.Kafka:
break;
case TracerInstrumentation.RabbitMq:
break;
case TracerInstrumentation.OracleMda:
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

namespace OpenTelemetry.AutoInstrumentation.Instrumentations.Kafka;
namespace OpenTelemetry.AutoInstrumentation.Instrumentations;

// https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/messaging/messaging-spans.md#messaging-attributes
internal static class MessagingAttributes
Expand All @@ -12,6 +12,9 @@ internal static class Keys
public const string MessagingOperation = "messaging.operation";
public const string DestinationName = "messaging.destination.name";
public const string ClientId = "messaging.client_id";
public const string MessageBodySize = "messaging.message.body.size";
public const string MessageId = "messaging.message.id";
public const string ConversationId = "messaging.message.conversation_id";

// https://github.com/open-telemetry/semantic-conventions/blob/v1.23.0/docs/messaging/kafka.md#span-attributes
internal static class Kafka
Expand All @@ -22,12 +25,25 @@ internal static class Kafka
public const string PartitionOffset = "messaging.kafka.message.offset";
public const string IsTombstone = "messaging.kafka.message.tombstone";
}

internal static class RabbitMq
{
public const string RoutingKey = "messaging.rabbitmq.destination.routing_key";
public const string DeliveryTag = "messaging.rabbitmq.delivery_tag";
}
}

internal static class Values
{
public const string KafkaMessagingSystemName = "kafka";
public const string PublishOperationName = "publish";
public const string ReceiveOperationName = "receive";
public const string ProcessOperationName = "process";

internal static class RabbitMq
{
public const string MessagingSystemName = "rabbitmq";
public const string DefaultExchangeName = "amq.default";
zacharycmontoya marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using OpenTelemetry.AutoInstrumentation.DuckTyping;

namespace OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.DuckTypes;

// wraps https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/a50334f2acb09fd16dc9cbd20ad1c6dd093d1d64/projects/RabbitMQ.Client/client/api/BasicGetResult.cs
internal interface IBasicGetResult : IDuckType
{
public string? Exchange { get; set; }

public string? RoutingKey { get; set; }

public IBasicProperties? BasicProperties { get; set; }

public ulong DeliveryTag { get; set; }

public IBody Body { get; set; }
}

// wraps https://github.com/rabbitmq/rabbitmq-dotnet-client/blob/a50334f2acb09fd16dc9cbd20ad1c6dd093d1d64/projects/RabbitMQ.Client/client/api/IBasicProperties.cs
internal interface IBasicProperties : IDuckType
{
IDictionary<string, object>? Headers { get; set; }

string? CorrelationId { get; set; }

string? MessageId { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using OpenTelemetry.AutoInstrumentation.DuckTyping;

namespace OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6.DuckTypes;

internal interface IBody : IDuckType
{
public int Length { get; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

namespace OpenTelemetry.AutoInstrumentation.Instrumentations.RabbitMq6;

internal static class IntegrationConstants
{
public const string RabbitMqByteCodeIntegrationName = "RabbitMq";
public const string RabbitMqAssemblyName = "RabbitMQ.Client";
public const string ModelBaseTypeName = "RabbitMQ.Client.Impl.ModelBase";
public const string EventingBasicConsumerTypeName = "RabbitMQ.Client.Events.EventingBasicConsumer";
public const string AsyncEventingBasicConsumerTypeName = "RabbitMQ.Client.Events.AsyncEventingBasicConsumer";
public const string ModelGeneratedTypeName = "RabbitMQ.Client.Framing.Impl.Model";
public const string BasicGetResultTypeName = "RabbitMQ.Client.BasicGetResult";
public const string BasicPropertiesInterfaceTypeName = "RabbitMQ.Client.IBasicProperties";
public const string BasicGetMethodName = "BasicGet";
public const string HandleBasicDeliverMethodName = "HandleBasicDeliver";
public const string BasicPublishMethodName = "_Private_BasicPublish";
public const string MinSupportedVersion = "6.0.0";
public const string MaxSupportedVersion = "6.*.*";
}
Loading
Loading