From d66f55e34b5d705d635ea8ca92ec2ae799924cba Mon Sep 17 00:00:00 2001 From: alex boten <223565+codeboten@users.noreply.github.com> Date: Thu, 12 Mar 2026 13:23:36 -0700 Subject: [PATCH 1/2] otelconf: support service resource detector This relies on the unreleased feature in the go SDK `WithService`. Not sure if it's ok to update the go.mod to use main or if we wait until the next release. Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com> --- otelconf/go.mod | 2 +- otelconf/go.sum | 2 ++ otelconf/resource.go | 5 +++-- otelconf/resource_test.go | 4 ++++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/otelconf/go.mod b/otelconf/go.mod index 9f89e4e41a1..6bd00798aac 100644 --- a/otelconf/go.mod +++ b/otelconf/go.mod @@ -20,7 +20,7 @@ require ( go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.42.0 go.opentelemetry.io/otel/log v0.18.0 go.opentelemetry.io/otel/metric v1.42.0 - go.opentelemetry.io/otel/sdk v1.42.0 + go.opentelemetry.io/otel/sdk v1.42.1-0.20260312144007-6d79ac393692 go.opentelemetry.io/otel/sdk/log v0.18.0 go.opentelemetry.io/otel/sdk/log/logtest v0.18.0 go.opentelemetry.io/otel/sdk/metric v1.42.0 diff --git a/otelconf/go.sum b/otelconf/go.sum index 1430f003119..71f4feb6cf1 100644 --- a/otelconf/go.sum +++ b/otelconf/go.sum @@ -77,6 +77,8 @@ go.opentelemetry.io/otel/metric v1.42.0 h1:2jXG+3oZLNXEPfNmnpxKDeZsFI5o4J+nz6xUl go.opentelemetry.io/otel/metric v1.42.0/go.mod h1:RlUN/7vTU7Ao/diDkEpQpnz3/92J9ko05BIwxYa2SSI= go.opentelemetry.io/otel/sdk v1.42.0 h1:LyC8+jqk6UJwdrI/8VydAq/hvkFKNHZVIWuslJXYsDo= go.opentelemetry.io/otel/sdk v1.42.0/go.mod h1:rGHCAxd9DAph0joO4W6OPwxjNTYWghRWmkHuGbayMts= +go.opentelemetry.io/otel/sdk v1.42.1-0.20260312144007-6d79ac393692 h1:KxM/2erC3Bx97dBXg+Nx3NALLb1BKk2bZIJvpqR0LG8= +go.opentelemetry.io/otel/sdk v1.42.1-0.20260312144007-6d79ac393692/go.mod h1:xaSffVzFG55EcPDReZb7hNa30cBwL0AMXQgPeGkMPtk= go.opentelemetry.io/otel/sdk/log v0.18.0 h1:n8OyZr7t7otkeTnPTbDNom6rW16TBYGtvyy2Gk6buQw= go.opentelemetry.io/otel/sdk/log v0.18.0/go.mod h1:C0+wxkTwKpOCZLrlJ3pewPiiQwpzycPI/u6W0Z9fuYk= go.opentelemetry.io/otel/sdk/log/logtest v0.18.0 h1:l3mYuPsuBx6UKE47BVcPrZoZ0q/KER57vbj2qkgDLXA= diff --git a/otelconf/resource.go b/otelconf/resource.go index 3c7257e91c8..ed35c4b2f81 100644 --- a/otelconf/resource.go +++ b/otelconf/resource.go @@ -24,8 +24,9 @@ func resourceOpts(detectors []ExperimentalResourceDetector) []resource.Option { if d.Process != nil { opts = append(opts, resource.WithProcess()) } - // TODO: implement service: - // Waiting on https://github.com/open-telemetry/opentelemetry-go/pull/7642 + if d.Service != nil { + opts = append(opts, resource.WithService()) + } } return opts } diff --git a/otelconf/resource_test.go b/otelconf/resource_test.go index d5d4558f6bc..0f62a8c2193 100644 --- a/otelconf/resource_test.go +++ b/otelconf/resource_test.go @@ -89,6 +89,7 @@ func TestResourceOptsWithDetectors(t *testing.T) { wantHostAttributes bool wantOSAttributes bool wantProcessAttribute bool + wantServiceAttribute bool }{ { name: "no-detectors", @@ -115,10 +116,12 @@ func TestResourceOptsWithDetectors(t *testing.T) { {Container: ExperimentalContainerResourceDetector{}}, {Host: ExperimentalHostResourceDetector{}}, {Process: ExperimentalProcessResourceDetector{}}, + {Service: ExperimentalServiceResourceDetector{}}, }, wantHostAttributes: true, wantOSAttributes: true, wantProcessAttribute: true, + wantServiceAttribute: true, }, } for _, tt := range tests { @@ -141,6 +144,7 @@ func TestResourceOptsWithDetectors(t *testing.T) { assert.Equal(t, tt.wantHostAttributes, attrSet[semconv.HostNameKey], "should have host.name attribute") assert.Equal(t, tt.wantOSAttributes, attrSet[semconv.OSTypeKey], "should have os.type attribute (from WithOS()") assert.Equal(t, tt.wantProcessAttribute, attrSet[semconv.ProcessPIDKey], "should have process.pid attribute") + assert.Equal(t, tt.wantServiceAttribute, attrSet[semconv.ServiceInstanceIDKey], "should have service.instance.id attribute") }) } } From 47f27b55edd2ee210825e524b74ee8902f38d4ce Mon Sep 17 00:00:00 2001 From: alex boten <223565+codeboten@users.noreply.github.com> Date: Fri, 13 Mar 2026 07:26:00 -0700 Subject: [PATCH 2/2] changelog, tidy Signed-off-by: alex boten <223565+codeboten@users.noreply.github.com> --- CHANGELOG.md | 1 + otelconf/go.sum | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ab8f2cb40b..3cc797b791b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ### Added - Configuration file can now be set via `OTEL_CONFIG_FILE` in `go.opentelemetry.io/contrib/otelconf`. (#8639) +- Added support for `service` resource detector in `go.opentelemetry.io/contrib/otelconf`. (#8674) ### Fixed diff --git a/otelconf/go.sum b/otelconf/go.sum index 71f4feb6cf1..86c9e5ba6fd 100644 --- a/otelconf/go.sum +++ b/otelconf/go.sum @@ -75,8 +75,6 @@ go.opentelemetry.io/otel/log v0.18.0 h1:XgeQIIBjZZrliksMEbcwMZefoOSMI1hdjiLEiiB0 go.opentelemetry.io/otel/log v0.18.0/go.mod h1:KEV1kad0NofR3ycsiDH4Yjcoj0+8206I6Ox2QYFSNgI= go.opentelemetry.io/otel/metric v1.42.0 h1:2jXG+3oZLNXEPfNmnpxKDeZsFI5o4J+nz6xUlaFdF/4= go.opentelemetry.io/otel/metric v1.42.0/go.mod h1:RlUN/7vTU7Ao/diDkEpQpnz3/92J9ko05BIwxYa2SSI= -go.opentelemetry.io/otel/sdk v1.42.0 h1:LyC8+jqk6UJwdrI/8VydAq/hvkFKNHZVIWuslJXYsDo= -go.opentelemetry.io/otel/sdk v1.42.0/go.mod h1:rGHCAxd9DAph0joO4W6OPwxjNTYWghRWmkHuGbayMts= go.opentelemetry.io/otel/sdk v1.42.1-0.20260312144007-6d79ac393692 h1:KxM/2erC3Bx97dBXg+Nx3NALLb1BKk2bZIJvpqR0LG8= go.opentelemetry.io/otel/sdk v1.42.1-0.20260312144007-6d79ac393692/go.mod h1:xaSffVzFG55EcPDReZb7hNa30cBwL0AMXQgPeGkMPtk= go.opentelemetry.io/otel/sdk/log v0.18.0 h1:n8OyZr7t7otkeTnPTbDNom6rW16TBYGtvyy2Gk6buQw=