open-telemetry / opentelemetry-php

The OpenTelemetry PHP Library
https://opentelemetry.io/docs/instrumentation/php/
Apache License 2.0
686 stars 170 forks source link

Why does just php sdk have the concept of scope for span? #1295

Closed changzee closed 1 month ago

changzee commented 2 months ago

I checked the official documentation and found that unlike other languages ​​​​(go, python), PHP SDK has two more APIs for scope activation and deativation, which is an unnecessary burden for users. Is it a bad idea?

brettmc commented 2 months ago

I think it's this part:

https://github.com/open-telemetry/opentelemetry-specification/tree/v1.32.0/specification/context#attach-context

The API MUST return a value that can be used as a Token to restore the previous Context

Java has something very similar, Context::makeCurrent: https://github.com/open-telemetry/opentelemetry-java/blob/main/context/src/main/java/io/opentelemetry/context/Context.java#L201 (note that it returns a Scope, which must be closed)

changzee commented 2 months ago

thanks for ur answer