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

Add support for OTEL_SERVICE_NAME environmental variable #2209

Merged
merged 18 commits into from
Aug 10, 2021

Conversation

pellared
Copy link
Member

@pellared pellared commented Jul 29, 2021

Partially addresses #1453.

This feature is important so that we can reuse the SDK in https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation.

Changes

  • ResourceBuilder.AddEnvironmentVariableDetector handles OTEL_SERVICE_NAME
    environmental variable.

TODO

@pellared pellared requested a review from a team July 29, 2021 12:57
/// Adds resource attributes parsed from an environment variable to a
/// <see cref="ResourceBuilder"/> following the <a
/// Adds resource attributes parsed from OTEL_RESOURCE_ATTRIBUTES, OTEL_SERVICE_NAME environment variables
/// to a <see cref="ResourceBuilder"/> following the <a
/// href="https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#specifying-resource-information-via-an-environment-variable">Resource
/// SDK</a>.
/// </summary>
/// <param name="resourceBuilder"><see cref="ResourceBuilder"/>.</param>
/// <returns>Returns <see cref="ResourceBuilder"/> for chaining.</returns>
public static ResourceBuilder AddEnvironmentVariableDetector(this ResourceBuilder resourceBuilder)
Copy link
Member Author

Choose a reason for hiding this comment

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

Couldn't this detector be out-of-the-box? This is what other languages do.

For sure something for a separate PR and maybe even needs some GH Issue for discussion.

Copy link
Member

Choose a reason for hiding this comment

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

+1 on making this out-of-the-box

Copy link
Member Author

Choose a reason for hiding this comment

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

I will make a separate PR to address it

@codecov
Copy link

codecov bot commented Jul 29, 2021

Codecov Report

Merging #2209 (48b041f) into main (f644373) will decrease coverage by 0.02%.
The diff coverage is 68.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2209      +/-   ##
==========================================
- Coverage   80.17%   80.14%   -0.03%     
==========================================
  Files         226      227       +1     
  Lines        7161     7173      +12     
==========================================
+ Hits         5741     5749       +8     
- Misses       1420     1424       +4     
Impacted Files Coverage Δ
...OpenTelemetry/Resources/OtelEnvResourceDetector.cs 82.35% <33.33%> (ø)
...lemetry/Resources/OtelServiceNameEnvVarDetector.cs 75.00% <75.00%> (ø)
...enTelemetry/Resources/ResourceBuilderExtensions.cs 88.46% <100.00%> (ø)
...Zipkin/Implementation/ZipkinExporterEventSource.cs 63.63% <0.00%> (-9.10%) ⬇️
...ter.ZPages/Implementation/ZPagesActivityTracker.cs 97.14% <0.00%> (-2.86%) ⬇️
...Telemetry/Internal/SelfDiagnosticsEventListener.cs 97.63% <0.00%> (+0.78%) ⬆️

* [Instrumentation](#instrumentation)
* [Processor](#processor)
* [Resource](#resource)
* [Sampler](#sampler)
* [Advanced topics](#advanced-topics)
* [Propagators](#propagators)
* [Troubleshooting](#troubleshooting)
* [Configuration Parameters](#configuration-parameters)
* [Remarks](#remarks)
Copy link
Member

Choose a reason for hiding this comment

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

Both Configuration Parameters and Remarks seem to be too detailed and generic for the ToC. Perhaps we want to remove the H3 (e.g. replace ### Remarks with **Remarks:**).

Copy link
Member Author

Choose a reason for hiding this comment

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

@open-telemetry/dotnet-maintainers WDYT - should I change it?

BTW I think that the Propagators section should be under Tracing configuration - and not under Advanced topics.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will make a separate PR for it as I did not get feedback on what is the preference

src/OpenTelemetry/README.md Outdated Show resolved Hide resolved
Co-authored-by: Reiley Yang <reyang@microsoft.com>
@pellared
Copy link
Member Author

Flaky test:

Failed OpenTelemetry.Instrumentation.AspNetCore.Tests.MetricTests.RequestMetricIsCaptured [113 ms]
  Error Message:
   System.Exception : Unsupported Type
  Stack Trace:
     at OpenTelemetry.Metrics.SumMetricAggregator.get_Sum() in /home/runner/work/opentelemetry-dotnet/opentelemetry-dotnet/src/OpenTelemetry/Metrics/MetricAggregators/SumMetricAggregator.cs:line 74
   at OpenTelemetry.Instrumentation.AspNetCore.Tests.MetricTests.RequestMetricIsCaptured() in /home/runner/work/opentelemetry-dotnet/opentelemetry-dotnet/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/MetricTests.cs:line 93
--- End of stack trace from previous location ---
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.Exception: exception description
         at OpenTelemetry.Instrumentation.AspNetCore.Tests.IncomingRequestsCollectionsIsAccordingToTheSpecTests.TestCallbackMiddlewareImpl.ProcessAsync(HttpContext context) in /home/runner/work/opentelemetry-dotnet/opentelemetry-dotnet/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs:line 176
         at TestApp.AspNetCore._5._0.CallbackMiddleware.InvokeAsync(HttpContext context) in /home/runner/work/opentelemetry-dotnet/opentelemetry-dotnet/test/TestApp.AspNetCore.5.0/CallbackMiddleware.cs:line 35
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
warn: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[2]
      The response has already started, the error page middleware will not be executed.
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
      An unhandled exception has occurred while executing the request.
      System.Exception: exception description
         at OpenTelemetry.Instrumentation.AspNetCore.Tests.IncomingRequestsCollectionsIsAccordingToTheSpecTests.TestCallbackMiddlewareImpl.ProcessAsync(HttpContext context) in /home/runner/work/opentelemetry-dotnet/opentelemetry-dotnet/test/OpenTelemetry.Instrumentation.AspNetCore.Tests/IncomingRequestsCollectionsIsAccordingToTheSpecTests.cs:line 176
         at TestApp.AspNetCore._5._0.CallbackMiddleware.InvokeAsync(HttpContext context) in /home/runner/work/opentelemetry-dotnet/opentelemetry-dotnet/test/TestApp.AspNetCore.5.0/CallbackMiddleware.cs:line 35
         at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)
warn: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[2]
      The response has already started, the error page middleware will not be executed.

src/OpenTelemetry/README.md Outdated Show resolved Hide resolved
src/OpenTelemetry/README.md Outdated Show resolved Hide resolved
@pellared pellared requested a review from pjanotti July 30, 2021 06:50
@pellared pellared requested review from CodeBlanch and reyang July 30, 2021 18:33
Copy link
Member

@CodeBlanch CodeBlanch left a comment

Choose a reason for hiding this comment

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

LGTM

@pellared pellared closed this Jul 30, 2021
@pellared pellared reopened this Jul 30, 2021
@pellared
Copy link
Member Author

Any idea why EasyCLA is not being triggered?

@cijothomas
Copy link
Member

Any idea why EasyCLA is not being triggered?

no! same issue with another PR also

@linux-foundation-easycla
Copy link

linux-foundation-easycla bot commented Jul 31, 2021

CLA Signed

The committers are authorized under a signed CLA.

@pellared
Copy link
Member Author

pellared commented Aug 2, 2021

@cijothomas EasyCLA is working

@pellared
Copy link
Member Author

pellared commented Aug 6, 2021

@open-telemetry/dotnet-maintainers PTAL

@cijothomas cijothomas merged commit 24226a5 into open-telemetry:main Aug 10, 2021
@pellared pellared deleted the otel-service-name branch August 10, 2021 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants