Skip to content

added: peer service attribute to Guzzle#581

Open
paulgrav wants to merge 1 commit into
open-telemetry:mainfrom
paulgrav:paulgrav/peerservice
Open

added: peer service attribute to Guzzle#581
paulgrav wants to merge 1 commit into
open-telemetry:mainfrom
paulgrav:paulgrav/peerservice

Conversation

@paulgrav

Copy link
Copy Markdown

The HttpClientInstrumentation sets the PEER_SERVICE attribute whilst GuzzleInstrumentation.php does not.

Grafana’s Traces Drilldown view uses the PEER_SERVICE attribute to make the spans more readable.

This PR aligns behaviour between the two instrumentations.

@paulgrav
paulgrav requested a review from a team as a code owner May 20, 2026 14:09
@paulgrav
paulgrav marked this pull request as draft May 20, 2026 14:14
@bobstrecansky

Copy link
Copy Markdown
Contributor

@paulgrav - we are actively working on fixing CI - once your draft is ready for review, I'll review it and merge.

@paulgrav
paulgrav marked this pull request as ready for review May 20, 2026 14:29
->spanBuilder(sprintf('%s', $request->getMethod()))
->setParent($parentContext)
->setSpanKind(SpanKind::KIND_CLIENT)
->setAttribute(TraceAttributes::PEER_SERVICE, $request->getUri()->getHost())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The schematic convention says:

The service.name of the remote service. SHOULD be equal to the actual service.name resource attribute of the remote service if any.

Are we sure that the $request->getUri()->getHost() will return the service.name here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

In that case then perhaps neither HttpClientInstrumentation nor GuzzleInstrumentation should set PEER_SERVICE?

Only the client of those libraries can know the PEER_SERVICE name, but there’s no good way to set it unless you write your own hooks.

For where I work, the host name would make a good proxy for the service.name.

I’d like to know the thinking behind this: line 65

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@paulgrav, I mean, I was expecting this, but at the same time, I don't think having something configured incorrectly elsewhere is a good justification for continuing the same (incorrect) pattern in new places. A much better approach would be to fix the existing incorrect behavior rather than following it.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I can’t disagree. Looking at HttpClientInstrumentation, the PEER_SERVICE attribute should probably be SERVICE_ADDRESS.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure what is SERVICE_ADDRESS, but I can only think of this attribute: https://opentelemetry.io/docs/specs/semconv/registry/attributes/network/#network-peer-address

And, if we ALL think that's the right one, it should be updated everywhere.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@bobstrecansky / @ChrisLightfootWild, what do you say about the existing instrumentations that use service.name whereas server.address should have been used. Can we just change it?

@paulgrav provided such an example:
https://github.com/paulgrav/opentelemetry-php-contrib/blob/38f145c1e29b406110c94999772def3e0557bf52/src/Instrumentation/Symfony/src/HttpClientInstrumentation.php#L65

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The way I'm reading: https://opentelemetry.io/docs/specs/semconv/general/attributes/

is:

service.name and server.address serve two completely different scopes. service.name identifies the logical application emitting the telemetry, while server.address is a network attribute identifying the specific host or IP of a target system being called

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm wondering if the Github history will tell us anything here, or if it was just a mistake.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think server.address is the correct way forward. With the lacking functionality to do service mapping ideally being added to in future 🤔

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