Skip to content
Draft
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 @@ -44,6 +44,7 @@ NETRUNTIME
Npgsql
NSERVICEBUS
omnisharp
OPAMP
OPENTRACING
OPERATINGSYSTEM
ORACLEMDA
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This component adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.h
available for [SqlClient instrumentation](https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/4343).
This is disabled by default and can be enabled via the
`OTEL_DOTNET_AUTO_SQLCLIENT_NETFX_ILREWRITE_ENABLED` environment variable.
- Experimental support for OpAMP (by default the client is disabled).

### Changed

Expand Down
8 changes: 8 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,3 +508,11 @@ instead.
| `OTEL_LOG_LEVEL` | SDK log level. (supported values: `none`,`error`,`warn`,`info`,`debug`) | `info` | [Stable](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `OTEL_DOTNET_AUTO_LOGGER` | AutoInstrumentation diagnostic logs sink. (supported values: `none`,`file`,`console`) | `file` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `OTEL_DOTNET_AUTO_LOG_FILE_SIZE` | Maximum size (in bytes) of a single log file created by the Auto Instrumentation | 10 485 760 (10 MB) | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |

## OpAMP Client

| Environment variable | Description | Default value | Status |
|------------------------------------------|--------------------------------------------|-----------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|
| `OTEL_DOTNET_AUTO_OPAMP_ENABLED` | Enables OpAMP client. | `false` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `OTEL_DOTNET_AUTO_OPAMP_SERVER_URL` | OpAMP server url. | `https://localhost:4318/v1/opamp` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
| `OTEL_DOTNET_AUTO_OPAMP_CONNECTION_TYPE` | OpAMP connection type (http or websocket). | `http` | [Experimental](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/versioning-and-stability.md) |
17 changes: 17 additions & 0 deletions docs/file-based-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,23 @@ instrumentation/development:
bridge_enabled: true
```

### OpAMP

``` yaml
opamp:
# Configure if OpAMP client is enabled.
# If omitted or null, the client is disabled.
enabled: false
# Configure the server endpoint. If not explicitly set, a default
# URL is returned based on the connection_type.
# connection_type:
# • connection_type: http -> https://localhost:4318/v1/opamp
# • connection_type: websocket -> wss://localhost:4318/v1/opamp
server_url: https://localhost:4318/v1/opamp
# Configure the type of connection used to communicate with the server (for example, http or websocket).
connection_type: http
```

### Configuration based instrumentation

Documentation for configuration based instrumentation can be found in [nocode-instrumentation.md](nocode-instrumentation.md).
1 change: 1 addition & 0 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<PackageVersion Include="OpenTelemetry.Instrumentation.Runtime" Version="1.13.0" />
<PackageVersion Include="OpenTelemetry.Instrumentation.SqlClient" Version="1.13.0-beta.1" />
<PackageVersion Include="OpenTelemetry.Instrumentation.StackExchangeRedis" Version="1.13.0-beta.1" />
<PackageVersion Include="OpenTelemetry.OpAmp.Client" Version="0.1.0-alpha.1" />
<PackageVersion Include="OpenTelemetry.Shims.OpenTracing" Version="1.13.1-beta.1" />
<PackageVersion Include="OpenTelemetry.Resources.Azure" Version="1.13.0-beta.1" />
<PackageVersion Include="OpenTelemetry.Resources.Container" Version="1.13.0-beta.1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,49 @@
<PackageVersion Include="System.ValueTuple" Version="4.6.1" />
</ItemGroup>

<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net462" Condition=" '$(TargetFramework)' == 'net462' " />
<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net462" Condition=" '$(TargetFramework)' == 'net462' ">
<PackageVersion Include="Google.Protobuf" Version="3.31.1" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
</ItemGroup>

<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net47" Condition=" '$(TargetFramework)' == 'net47' " />
<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net47" Condition=" '$(TargetFramework)' == 'net47' ">
<PackageVersion Include="Google.Protobuf" Version="3.31.1" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.IO" Version="4.3.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Runtime" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
</ItemGroup>

<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net471" Condition=" '$(TargetFramework)' == 'net471' " />
<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net471" Condition=" '$(TargetFramework)' == 'net471' ">
<PackageVersion Include="Google.Protobuf" Version="3.31.1" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.IO" Version="4.3.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Runtime" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
</ItemGroup>

<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net472" Condition=" '$(TargetFramework)' == 'net472' " />
<ItemGroup Label="Transient dependencies auto-generated by GenerateNetFxTransientDependencies for net472" Condition=" '$(TargetFramework)' == 'net472' ">
<PackageVersion Include="Google.Protobuf" Version="3.31.1" />
<PackageVersion Include="System.Collections.Immutable" Version="8.0.0" />
<PackageVersion Include="System.IO" Version="4.3.0" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Runtime" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Algorithms" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Encoding" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.Primitives" Version="4.3.0" />
<PackageVersion Include="System.Security.Cryptography.X509Certificates" Version="4.3.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()

assembly_version_redirect_map_.insert({
{ 462, {
{ L"Google.Protobuf", {3, 31, 1, 0} },
{ L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 10} },
Expand Down Expand Up @@ -51,6 +52,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"OpenTelemetry.Instrumentation.Runtime", {1, 13, 0, 708} },
{ L"OpenTelemetry.Instrumentation.SqlClient", {1, 13, 0, 709} },
{ L"OpenTelemetry.Instrumentation.Wcf", {1, 13, 0, 698} },
{ L"OpenTelemetry.OpAmp.Client", {0, 1, 0, 664} },
{ L"OpenTelemetry.Resources.Azure", {1, 13, 0, 711} },
{ L"OpenTelemetry.Resources.Host", {1, 13, 0, 683} },
{ L"OpenTelemetry.Resources.OperatingSystem", {1, 13, 0, 713} },
Expand All @@ -62,6 +64,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"System.Buffers", {4, 0, 5, 0} },
{ L"System.Collections", {4, 0, 11, 0} },
{ L"System.Collections.Concurrent", {4, 0, 11, 0} },
{ L"System.Collections.Immutable", {8, 0, 0, 0} },
{ L"System.Collections.NonGeneric", {4, 0, 3, 0} },
{ L"System.Collections.Specialized", {4, 0, 3, 0} },
{ L"System.ComponentModel", {4, 0, 1, 0} },
Expand Down Expand Up @@ -163,6 +166,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"System.Xml.XPath.XDocument", {4, 1, 0, 0} },
}},
{ 470, {
{ L"Google.Protobuf", {3, 31, 1, 0} },
{ L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 10} },
Expand Down Expand Up @@ -195,6 +199,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"OpenTelemetry.Instrumentation.Runtime", {1, 13, 0, 708} },
{ L"OpenTelemetry.Instrumentation.SqlClient", {1, 13, 0, 709} },
{ L"OpenTelemetry.Instrumentation.Wcf", {1, 13, 0, 698} },
{ L"OpenTelemetry.OpAmp.Client", {0, 1, 0, 664} },
{ L"OpenTelemetry.Resources.Azure", {1, 13, 0, 711} },
{ L"OpenTelemetry.Resources.Host", {1, 13, 0, 683} },
{ L"OpenTelemetry.Resources.OperatingSystem", {1, 13, 0, 713} },
Expand All @@ -206,6 +211,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"System.Buffers", {4, 0, 5, 0} },
{ L"System.Collections", {4, 0, 11, 0} },
{ L"System.Collections.Concurrent", {4, 0, 11, 0} },
{ L"System.Collections.Immutable", {8, 0, 0, 0} },
{ L"System.Collections.NonGeneric", {4, 0, 3, 0} },
{ L"System.Collections.Specialized", {4, 0, 3, 0} },
{ L"System.ComponentModel", {4, 0, 1, 0} },
Expand Down Expand Up @@ -307,6 +313,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"System.Xml.XPath.XDocument", {4, 1, 0, 0} },
}},
{ 471, {
{ L"Google.Protobuf", {3, 31, 1, 0} },
{ L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 10} },
Expand Down Expand Up @@ -338,6 +345,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"OpenTelemetry.Instrumentation.Runtime", {1, 13, 0, 708} },
{ L"OpenTelemetry.Instrumentation.SqlClient", {1, 13, 0, 709} },
{ L"OpenTelemetry.Instrumentation.Wcf", {1, 13, 0, 698} },
{ L"OpenTelemetry.OpAmp.Client", {0, 1, 0, 664} },
{ L"OpenTelemetry.Resources.Azure", {1, 13, 0, 711} },
{ L"OpenTelemetry.Resources.Host", {1, 13, 0, 683} },
{ L"OpenTelemetry.Resources.OperatingSystem", {1, 13, 0, 713} },
Expand All @@ -346,6 +354,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} },
{ L"OpenTracing", {0, 12, 1, 0} },
{ L"System.Buffers", {4, 0, 5, 0} },
{ L"System.Collections.Immutable", {8, 0, 0, 0} },
{ L"System.Data.Common", {4, 2, 0, 0} },
{ L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 10} },
{ L"System.Diagnostics.StackTrace", {4, 1, 0, 0} },
Expand All @@ -368,6 +377,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"System.Xml.XPath.XDocument", {4, 1, 0, 0} },
}},
{ 472, {
{ L"Google.Protobuf", {3, 31, 1, 0} },
{ L"Microsoft.Bcl.AsyncInterfaces", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration", {9, 0, 0, 10} },
{ L"Microsoft.Extensions.Configuration.Abstractions", {9, 0, 0, 10} },
Expand Down Expand Up @@ -399,6 +409,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"OpenTelemetry.Instrumentation.Runtime", {1, 13, 0, 708} },
{ L"OpenTelemetry.Instrumentation.SqlClient", {1, 13, 0, 709} },
{ L"OpenTelemetry.Instrumentation.Wcf", {1, 13, 0, 698} },
{ L"OpenTelemetry.OpAmp.Client", {0, 1, 0, 664} },
{ L"OpenTelemetry.Resources.Azure", {1, 13, 0, 711} },
{ L"OpenTelemetry.Resources.Host", {1, 13, 0, 683} },
{ L"OpenTelemetry.Resources.OperatingSystem", {1, 13, 0, 713} },
Expand All @@ -407,6 +418,7 @@ void CorProfiler::InitNetFxAssemblyRedirectsMap()
{ L"OpenTelemetry.Shims.OpenTracing", {1, 0, 0, 0} },
{ L"OpenTracing", {0, 12, 1, 0} },
{ L"System.Buffers", {4, 0, 5, 0} },
{ L"System.Collections.Immutable", {8, 0, 0, 0} },
{ L"System.Diagnostics.DiagnosticSource", {9, 0, 0, 10} },
{ L"System.IO.Pipelines", {9, 0, 0, 10} },
{ L"System.Memory", {4, 0, 5, 0} },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ internal partial class ConfigurationKeys
/// </summary>
public const string SetupSdk = "OTEL_DOTNET_AUTO_SETUP_SDK";

/// <summary>
/// Configuration key for enabling OpAmp client.
/// </summary>
public const string OpAmpEnabled = "OTEL_DOTNET_AUTO_OPAMP_ENABLED";

/// <summary>
/// Configuration key for OpAmp server url.
/// </summary>
public const string OpAmpServerUrl = "OTEL_DOTNET_AUTO_OPAMP_SERVER_URL";

/// <summary>
/// Configuration key for OpAmp server connection type.
/// </summary>
public const string OpAmpConnectionType = "OTEL_DOTNET_AUTO_OPAMP_CONNECTION_TYPE";

/// <summary>
/// Configuration key for enabling all instrumentations.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using Vendors.YamlDotNet.Serialization;

namespace OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;

internal class OpAmpConfiguration
{
/// <summary>
/// Gets or sets a value indicating whether the OpAmp client is enabled.
/// </summary>
[YamlMember(Alias = "enabled")]
public bool? Enabled { get; set; }

/// <summary>
/// Gets or sets the URL of the server to which the application connects.
/// </summary>
[YamlMember(Alias = "server_url")]
public string? ServerUrl { get; set; }

/// <summary>
/// Gets or sets the type of connection used for communication.
/// </summary>
[YamlMember(Alias = "connection_type")]
public string? ConnectionType { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,10 @@ internal class YamlConfiguration
/// </summary>
[YamlMember(Alias = "no_code/development")]
public NoCodeConfiguration? NoCode { get; set; }

/// <summary>
/// Gets or sets the OpAMP settings.
/// </summary>
[YamlMember(Alias = "opamp")]
public OpAmpConfiguration? OpAmp { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0

using OpenTelemetry.AutoInstrumentation.Configurations.FileBasedConfiguration;
using OpenTelemetry.AutoInstrumentation.Logging;

namespace OpenTelemetry.AutoInstrumentation.Configurations;

internal class OpAmpSettings : Settings
{
private static readonly IOtelLogger Logger = OtelLogging.GetLogger();

/// <summary>
/// Gets a value indicating whether the OpAmp client is enabled.
/// </summary>
public bool OpAmpClientEnabled { get; private set; }

/// <summary>
/// Gets the URL of the server to which the application connects.
/// </summary>
public Uri? ServerUrl { get; private set; }

/// <summary>
/// Gets the type of connection used for communication.
/// </summary>
public string? ConnectionType { get; private set; }

protected override void OnLoadEnvVar(Configuration configuration)
{
OpAmpClientEnabled = configuration.GetBool(ConfigurationKeys.OpAmpEnabled) ?? false;
ServerUrl = GetServerUrl(configuration.GetString(ConfigurationKeys.OpAmpServerUrl), configuration.FailFast);
ConnectionType = GetConnectionType(configuration.GetString(ConfigurationKeys.OpAmpConnectionType), configuration.FailFast);
}

protected override void OnLoadFile(YamlConfiguration configuration)
{
OpAmpClientEnabled = configuration.OpAmp?.Enabled ?? false;
ServerUrl = GetServerUrl(configuration.OpAmp?.ServerUrl, configuration.FailFast);
ConnectionType = GetConnectionType(configuration.OpAmp?.ConnectionType, configuration.FailFast);
}

private static Uri? GetServerUrl(string? configurationValue, bool failFast)
{
if (string.IsNullOrWhiteSpace(configurationValue))
{
// indicates that the default value should be used
return null;
}

try
{
return new Uri(configurationValue);
}
catch (Exception ex)
{
var errorMessage = $"OpAMP server URL configuration has an invalid value: '{configurationValue}'.";
Logger.Error(ex, errorMessage);

if (failFast)
{
throw new InvalidOperationException(errorMessage, ex);
}

return null;
}
}

private static string? GetConnectionType(string? configurationValue, bool failFast)
{
if (string.IsNullOrWhiteSpace(configurationValue))
{
// indicates that the default value should be used
return null;
}

var isValid = configurationValue!.ToLower() is "http" or "websocket";
if (isValid)
{
return configurationValue!.ToLower();
}

var unsupportedMessage = $"OpAMP connection type configuration has an invalid value: '{configurationValue}'.";
Logger.Error(unsupportedMessage);

if (failFast)
{
throw new NotSupportedException(unsupportedMessage);
}

return null;
}
}
Loading