opentelemetry-dotnet icon indicating copy to clipboard operation
opentelemetry-dotnet copied to clipboard

Refine the default resource service.name

Open pellared opened this issue 3 years ago • 11 comments

Ideally, the SDK should try the name of the entry assembly first and only if that fails fallback to the process name. This way it gets better default names for applications started via dotnet MySvc.dll which is currently resolves dotnet as the process name.

Do you see any problem with such a change?

Originally posted by @pjanotti in https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/pull/312#discussion_r782478960

pellared avatar Jan 12 '22 18:01 pellared

This sounds reasonable change.

https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/resource/semantic_conventions/README.md#service

cijothomas avatar Jan 13 '22 01:01 cijothomas

If the value was not specified, SDKs MUST fallback to unknown_service: concatenated with process.executable.name, e.g. unknown_service:bash

As far as I understand we would first need to propose a change in the specification to allow different values than process.executable.name such as "name of the main program entry" (for .NET it can be the executing assembly, for Python probably the name of the main module). Can you confirm, please?

pellared avatar Jan 13 '22 13:01 pellared

mm. Yes it feels some change to spec would be needed, given its a "MUST" in the spec.

cijothomas avatar Jan 13 '22 16:01 cijothomas

Was there any further discussions on this since January? This default is so bad that it basically enforces every application to change it otherwise telemetry info becomes nearly impossible to follow.

Seeing stuff like unknown_service_w3wp or unknown_service_dotnet is completely useless as it basically conflates every single application if they do not set a value manually.

julealgon avatar Jul 19 '22 13:07 julealgon

@julealgon None that I am aware of. Feel free to create a PR/issue in OTel specification or join their SIG meeting (more info here).

pellared avatar Jul 19 '22 15:07 pellared

This would be a really great change in my mind as well. Having better defaults or a way to change this on a per application basis is going to be the only viable solution here.

For IIS this needs to be something related to the VDIR name similar to what DataDog does.

Kronos11 avatar Feb 14 '23 16:02 Kronos11

@cijothomas what we talked about last night in the SIG, maybe I didn't do the request justice.

Kronos11 avatar Feb 15 '23 16:02 Kronos11

Per https://github.com/open-telemetry/opentelemetry-specification/issues/3210 we could simply create a new resource detector that sets the service.name resource based on the name of the entry assembly.

pellared avatar Mar 07 '23 16:03 pellared

Per open-telemetry/opentelemetry-specification#3210 we could simply create a new resource detector that sets the service.name resource based on the name of the entry assembly.

@pellared what about a resource detector implementation that relies on this?

  • https://github.com/dotnet/extensions/tree/main/src/Libraries/Microsoft.Extensions.AmbientMetadata.Application

It could then cover both the service.name and service.version attributes, and potentially also the deployment.environment one.

julealgon avatar Feb 16 '24 15:02 julealgon

Another alternative option: one could also overload the AddService extension method on the resource builder, similar as it's done for the service instance id (autoGenerateServiceInstanceId). So you could call

resourceBuilder.AddService(autoGenerateServiceName: true);

I wouldn't see this as a violation of the specification, as the user has to explicitly request the auto-generation of a service name.

Having a resource detector for this is viable too, however, then this makes it 4 ways users have to specify a service name, which seems quite a lot (via AddService, via the resource detector, via OTEL_SERVICE_NAME, and via OTEL_RESOURCE_ATTRIBUTES).

pyohannes avatar Feb 16 '24 16:02 pyohannes

FYI here is a code that we have in .NET Automatic Instrumentation: https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/blob/42c51e6273df04cfe54e08ae073939cf515c2e93/src/OpenTelemetry.AutoInstrumentation/Configurations/ResourceConfigurator.cs#L51

pellared avatar Feb 19 '24 10:02 pellared