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

Auto Resource Implementation in dotnet similar to Java #2752

Closed
swetharavichandrancisco opened this issue Dec 16, 2021 · 6 comments
Closed
Labels
enhancement New feature or request

Comments

@swetharavichandrancisco

Purpose of the Feature Request:

Creation of Automatic Resource Attributes, especially looking to add container.id to resource metadata
Corresponding JAVA PR posted below,

Current Behavior in Java:

In Java, We have ResourceProvider Interface that are implemented in the below classes

All these Providers are read OOTB in OpenTelemetryResourceAutoConfiguration

and it is configured in the below file,

Current Behavior in DotNet:

In DotNet, We have ResourceBuilderExtensions class that adds Semantic Attributes with Dedicated Environment Variable/SDK-provided Default Value like service, opentelemetry SDK

From the customer application, we still have to call the respective api's for the resources to be added.
Below is the sample code,
var tracerProvider = Sdk.CreateTracerProviderBuilder() .SetResourceBuilder(ResourceBuilder.CreateEmpty().AddService("test")) .AddSource("Sample.DistributedTracing") .AddConsoleExporter() .Build()
Currently, there is no way to add Resources automatically.

Expected/Proposed Solution:

Can we have something similar to Java? Implement ResourceProviders in DotNet and ResourceBuilder class can pick all the ResourceProviders. We should also provide a way to configure ResourceProviders.

Thanks.

@swetharavichandrancisco swetharavichandrancisco added the enhancement New feature or request label Dec 16, 2021
@swetharavichandrancisco
Copy link
Author

I can work on the feature as well

@alanwest
Copy link
Member

alanwest commented Dec 17, 2021

I can work on the feature as well

@swetharavichandrancisco sounds good!

The specification has a few words about resource detectors that my prove useful https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/sdk.md#detecting-resource-information-from-the-environment

You might also take a look at the implementation for the resource detector for the OTEL_RESOURCE_ATTRIBUTES environment variable https://github.com/open-telemetry/opentelemetry-dotnet/blob/6b7f2dd77cf9d37260a853fcc95f7b77e296065d/src/OpenTelemetry/Resources/OtelEnvResourceDetector.cs

@swetharavichandrancisco
Copy link
Author

swetharavichandrancisco commented Dec 17, 2021

Thank you @alanwest for sharing the information.

I did take a look at the specifications. All these Resource information are detected via environment variables.
I'm specifically looking to add resource information OOTB.

@alanwest, Does that mean that I can proceed to work on the feature request?

@alanwest
Copy link
Member

@swetharavichandrancisco Yes, your contributions would be welcome! I think it would be great to additional resource detectors for things like Docker.

I think the title of that section of the spec is misleading... it is not just about detection via environment variables, but more generally the environment the application is running in like Docker or a cloud vendor. It provides some guidance that you'll like need to take into account.

Custom resource detectors related to generic platforms (e.g. Docker, Kubernetes) or vendor specific environments (e.g. EKS, AKS, GKE) MUST be implemented as packages separate from the SDK.

So, just as Java has separated out their resource detectors into a package, we'll likely need to do the same.

If you're proposing to build both additional resource detectors and also an auto resource configuration mechanism like Java, I think it would be best to split up these efforts.

@cijothomas
Copy link
Member

Exposing this as public is likely all that we need :

internal interface IResourceDetector

@swetharavichandrancisco swetharavichandrancisco changed the title Automatic Resource Detection in dotnet similar to Java Auto Resource Implementation in dotnet similar to Java Jan 13, 2022
@github-actions github-actions bot added the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jan 27, 2022
@cijothomas cijothomas removed the Stale Issues and pull requests which have been flagged for closing due to inactivity label Jan 27, 2022
@cijothomas
Copy link
Member

Closing as this is completed in #2897

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants