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

Default Resource should have service.name attribute #1744

Merged
merged 21 commits into from
Feb 1, 2021
Merged

Default Resource should have service.name attribute #1744

merged 21 commits into from
Feb 1, 2021

Conversation

Austin-Tan
Copy link
Member

Fixes recent OTel Spec change.

Changes

Instead of by default attaching a Telemetry SDK resource with package information, the default is attaching a one-tag service.name following the requirements specified in Resource.md.

Will have a follow-up PR to have exporters actually access this default.

For significant contributions please make sure you have completed the following items:

  • CHANGELOG.md updated for non-trivial changes
  • Design discussion issue #
  • Changes in public API reviewed

@Austin-Tan Austin-Tan requested a review from a team January 29, 2021 17:42
/// semantic conventions</a> for details.
/// </summary>
/// <returns>Created <see cref="ResourceBuilder"/>.</returns>
public static ResourceBuilder CreateSDK()
Copy link
Member

Choose a reason for hiding this comment

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

I think we should stick with the casing "Sdk" since it is used elsewhere (eg AddTelemetrySdk).

Copy link
Member

Choose a reason for hiding this comment

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

Also, do we need a CreateSdk? How will user know which one to call (CreateDefault() or CreatedSdk())? Probably better for us to give them just one path (pit of success).

What if we combined both into one thing?

public static ResourceBuilder CreateDefault(bool addTelemetrySdk = true)

Copy link
Member Author

Choose a reason for hiding this comment

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

Will fix the Sdk casing immediately. I like the idea of the optional parameter on default. This way we'll always have service.name and then optionally include the Telemetry SDK resource.

Copy link
Member

Choose a reason for hiding this comment

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

AddTelemetrySdk already exists on ResourceBuilder extensions, so why need it here again?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is this not where we would provide access to the Telemetry Resource? We previously used CreateDefault to just link directly to AddTelemetrySDK

Copy link
Member

@cijothomas cijothomas Jan 29, 2021

Choose a reason for hiding this comment

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

Users just need an API to add TelemetrySDK, which we already provide. There is no need of an additional method.
A user can do:

ResourceBuilder.CreateEmpty().AddTelemetrySdk() - Resource will only have telemetrysdk attributes.
or
ResourceBuilder.CreateDefault().AddTelemetrySdk() - Resource will have telemetrysdk attributes + the default. (default is service.name("unknownservice..."))
or
ResourceBuilder.CreateDefault().AddTelemetrySdk().AddServiceName("CijoService") - Resource will have telemetrysdk attributes + service.name ("CijoService"). Due the merge priority, "CijoService" overrides the default one.

Copy link
Member Author

Choose a reason for hiding this comment

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

This thinking makes a lot of sense to me. I'll remove the various extra things we introduced in this PR, and I like @CodeBlanch 's approach too but I think this is more elegant. Will not be implementing the optional parameter.

@codecov
Copy link

codecov bot commented Jan 29, 2021

Codecov Report

Merging #1744 (d8d0d53) into main (416a6c1) will increase coverage by 0.99%.
The diff coverage is 84.21%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1744      +/-   ##
==========================================
+ Coverage   83.14%   84.14%   +0.99%     
==========================================
  Files         193      187       -6     
  Lines        6005     5923      -82     
==========================================
- Hits         4993     4984       -9     
+ Misses       1012      939      -73     
Impacted Files Coverage Δ
...nTelemetry.Exporter.Jaeger/Implementation/Batch.cs 84.09% <ø> (+3.65%) ⬆️
...rc/OpenTelemetry.Exporter.Jaeger/JaegerExporter.cs 83.33% <72.72%> (-1.93%) ⬇️
src/OpenTelemetry/Resources/ResourceBuilder.cs 92.85% <100.00%> (+2.38%) ⬆️
...emetry.Exporter.Console/ConsoleActivityExporter.cs
...porter.Console/ConsoleExporterLoggingExtensions.cs
.../OpenTelemetry.Exporter.Console/ConsoleExporter.cs
...xporter.Console/ConsoleExporterHelperExtensions.cs
...lemetry.Exporter.Console/ConsoleExporterOptions.cs
...metry.Exporter.Console/ConsoleLogRecordExporter.cs
...rc/OpenTelemetry/Trace/TracerProviderBuilderSdk.cs 90.74% <0.00%> (+3.70%) ⬆️
... and 2 more

@johnduhart
Copy link
Contributor

Instead of by default attaching a Telemetry SDK resource with package information, the default is attaching a one-tag service.name following the requirements specified in Resource.md.

I'm not sure I agree with this interpretation, the spec says "at least". Including the telemetry.* attributes by default seems like best-practice.

@cijothomas
Copy link
Member

Including the telemetry.* attributes by default seems like best-practice.

Some exporters export all the resource attributes with every span. With this PR as is, If a user add Resource.Default - they'll get only the MUST have resource (servicename), instead of getting TelemetrySDK attributes as well.

But not opposed to making telemetrysdk to the Default itself. The spec about TelemetrySDK (https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions#telemetry-sdk), is not yet marked stable. So we should be able to do the following:

For 1.0.0, Resource.Default - only contain "service.name". If user want teleemtrySDK, they need to manually call AddTelemetrySdk.

Post 1.0.0, when Resource Semantic Conventions gets marked as stable, we can modify Resource.Default to include TelemetrySDK as well. (This shouldn't cause duplicates anyway, so would be backward compatible as well.)

Okay with this approach?

@johnduhart
Copy link
Contributor

Okay, that makes sense.

@@ -90,7 +90,7 @@ public static class ResourceBuilderExtensions
/// <summary>
/// Adds service information to a <see cref="ResourceBuilder"/>
/// following <a
/// href="https://github.com/open-telemetry/opentelemetry-specification/tree/main/specification/resource/semantic_conventions#telemetry-sdk">semantic
/// href="https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/resource/semantic_conventions#telemetry-sdk">semantic
Copy link
Member

Choose a reason for hiding this comment

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

this change is incorrect. the branch was named to "main" last week.

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 noticed this, but when I use .../master/... the link doesn't properly direct to the right part of the page. /main/ will show the warning but also direct to the right section of the page.
I'll still change it to master.

@@ -44,6 +44,10 @@ Released 2021-Jan-29
[#1501](https://github.com/open-telemetry/opentelemetry-dotnet/pull/1655)
for details on Metric release plans.
* Fix Resource attribute telemetry.sdk.version to have correct file version.
* Default `Resource` has been updated. No longer linked to Telemetry SDK,
Copy link
Member

Choose a reason for hiding this comment

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

I think a simple one liner like this is sufficient for changelog: Default resource will now contain service.name instead of telemetrysdk.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed. Also the line above it, issue #1501 redirects to PR #1655. is this intended?

@Austin-Tan Austin-Tan closed this Feb 1, 2021
@Austin-Tan Austin-Tan reopened this Feb 1, 2021
@cijothomas cijothomas merged commit 18db60d into open-telemetry:main Feb 1, 2021
@Austin-Tan Austin-Tan deleted the DefaultResourceServiceName branch February 1, 2021 21: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.

4 participants