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

OTLP Exported as default for .NET (Core) #343

Closed
wants to merge 7 commits into from
Closed
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: 0 additions & 1 deletion dev/envvars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ fi
export OTEL_DOTNET_TRACER_HOME="${CURDIR}/bin/tracer-home"
export OTEL_INTEGRATIONS="${CURDIR}/bin/tracer-home/integrations.json"
export OTEL_TRACE_DEBUG="1"
export OTEL_EXPORTER="zipkin"
export OTEL_DUMP_ILREWRITE_ENABLED="0"
export OTEL_CLR_ENABLE_INLINING="1"
export OTEL_PROFILER_EXCLUDE_PROCESSES="dotnet.exe,dotnet"
2 changes: 1 addition & 1 deletion docs/USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ The exporter is used to output the telemetry.

| Environment variable | Description | Default |
|-|-|-|
| `OTEL_EXPORTER` | The exporter to be used. The Tracer uses it to encode and dispatch traces. Available values are: `zipkin`, `jeager`, `otlp`. | |
| `OTEL_EXPORTER` | The exporter to be used. The Tracer uses it to encode and dispatch traces. Available values are: `zipkin`, `jeager`, `otlp`. | `otlp` for .NET (Core), `zipkin` for .NET Framework |
| `OTEL_EXPORTER_JAEGER_AGENT_HOST` | Hostname for the Jaeger agent. | `localhost` |
| `OTEL_EXPORTER_JAEGER_AGENT_PORT` | Port for the Jaeger agent. | `6831` |
| `OTEL_EXPORTER_OTLP_ENDPOINT` | Target endpoint for OTLP exporter. More details [here](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/protocol/exporter.md). | `http://localhost:4318` |
Expand Down
5 changes: 4 additions & 1 deletion samples/ConsoleApp/ConsoleApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@

<!-- Hack to fix SDK dependencies -->
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.0.3" />

<!-- Hack to make the otel exportert working for .NET 5.0 -->
<PackageReference Include="Grpc.Net.Client" Version="2.32.0" Condition="'$(TargetFramework)' == 'net5.0'"/>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want this merged then it should be documented in USAGE.md

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI #350

</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public class ConfigurationKeys
/// <summary>
/// Configuration key for the exporter to be used. The Tracer uses it to encode and
/// dispatch traces.
/// Default is <c>"Zipkin"</c>.
/// Default is <c>"otlp"</c> for .NET (Core).
/// Default is <c>"Zipkin"</c> for .NET Framework.
/// </summary>
public const string Exporter = "OTEL_EXPORTER";

Expand All @@ -42,7 +43,7 @@ public class ConfigurationKeys
public const string DisabledInstrumentations = "OTEL_DOTNET_TRACER_DISABLED_INSTRUMENTATIONS";

/// <summary>
/// Configuration key for colon (:) separated list of plugins repesented by <see cref="System.Type.AssemblyQualifiedName"/>.
/// Configuration key for colon (:) separated list of plugins represented by <see cref="System.Type.AssemblyQualifiedName"/>.
/// </summary>
public const string ProviderPlugins = "OTEL_DOTNET_TRACER_INSTRUMENTATION_PLUGINS";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using OpenTelemetry.Resources;
using OpenTelemetry.Trace;

Expand Down Expand Up @@ -75,16 +73,13 @@ private static TracerProviderBuilder SetExporter(this TracerProviderBuilder buil
// See: https://docs.microsoft.com/aspnet/core/grpc/troubleshoot#call-insecure-grpc-services-with-net-core-client
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
#endif
builder.AddOtlpExporter(options =>
{
options.ExportProcessorType = ExportProcessorType.Simple; // workaround for https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/issues/290
});
builder.AddOtlpExporter();
break;
case "":
case null:
break;
default:
throw new ArgumentOutOfRangeException("The exporter name is not recognised");
throw new ArgumentOutOfRangeException("The exporter name is not recognized");
}

return builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ private Settings(IConfigurationSource source)
throw new ArgumentNullException(nameof(source));
}

Exporter = source.GetString(ConfigurationKeys.Exporter);
Exporter = source.GetString(ConfigurationKeys.Exporter) ??
#if NETFRAMEWORK
"zipkin";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alternatively, for.NET Framework, we could still use the OTLP exporter, but set HTTP protocol

#else
"otlp";
#endif

LoadTracerAtStartup = source.GetBool(ConfigurationKeys.LoadTracerAtStartup) ?? true;
ConsoleExporterEnabled = source.GetBool(ConfigurationKeys.ConsoleExporterEnabled) ?? true;

Expand Down