open-telemetry / opentelemetry.io

The OpenTelemetry website and documentation
https://opentelemetry.io
Creative Commons Attribution 4.0 International
535 stars 1.17k forks source link

Follow-Up Issues for Resource Detection in .NET #1835

Open svrnm opened 2 years ago

svrnm commented 2 years ago
cartermp commented 2 years ago

Assigning myself here. The package does work, I just need to fit it in correctly with a good code sample.

cartermp commented 2 years ago

Blegh. Unfortunately stumped because it's to do with environments and there's wonky behavior:

Will need to investigate but I'll add the servicename stuff for now.

cartermp commented 2 years ago

Aha, this explains the service.instance.id being set: https://github.com/open-telemetry/opentelemetry-dotnet/blob/d7afc1bcb0092a56ac1ea55bfbcf5a9430c72cf9/src/OpenTelemetry/Resources/ResourceBuilderExtensions.cs#L54

svrnm commented 2 years ago
  • The package doesn't appear to actually work, as there is no container ID listed when the container is run

It's a corner case, but the package does not work if cgroupv2 is used, there's a work around, so far only implemented by JS. So, by any chance, can you run the container again and check if /proc/self/cgroup gives you something?

svrnm commented 2 years ago

Wanting to play around with dotnet anways, I just gave it a try:

I get some container.id (I use colima with docker engine)

$ docker run --rm -t -i dotnetty
Activity.TraceId:          a289ca5f184994a23f19aeec477e2882
Activity.SpanId:           9b0a995ef440242f
Activity.TraceFlags:           Recorded
Activity.ActivitySourceName: MyCompany.MyProduct.MyService
Activity.DisplayName: SayHello
Activity.Kind:        Internal
Activity.StartTime:   2022-10-11T09:17:59.6471556Z
Activity.Duration:    00:00:00.0003996
Activity.Tags:
    foo: 1
    bar: Hello, World!
    baz: [1,2,3]
Resource associated with Activity:
    container.id: b1e2f740d45828051ae474b34074c152c7a98409bfbdaf6f3c9781edc2e457c7
    service.name: MyCompany.MyProduct.MyService
    service.version: 1.0.0
    service.instance.id: 7c9de23c-7e67-433a-b25e-132d685a7c8f

When I overwrite the entrypoint with cat /proc/self/cgroup I see the following

❯ docker run --rm -t -i dotnetty cat /proc/self/cgroup
13:pids:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
12:hugetlb:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
11:net_prio:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
10:perf_event:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
9:net_cls:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
8:freezer:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
7:devices:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
6:memory:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
5:blkio:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
4:cpuacct:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
3:cpu:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
2:cpuset:/docker/9c742a2055836b7c0cc9583f062a9fccd9950f3fc22784dbbd1372f8f3738a72
1:name=openrc:/docker
0::/docker