You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the application is limited in its ability to add global Resource attributes. These attributes can only be set at the start of RUM (Real User Monitoring) sessions. Once the application has begun, there is no mechanism to dynamically add or modify these resource attributes throughout the application's lifetime.
also, there is no possibility to restart the session, because of that line of code:
public static void set(OpenTelemetry openTelemetry) {
synchronized (mutex) {
if (globalOpenTelemetry != null) {
throw new IllegalStateException(
"GlobalOpenTelemetry.set has already been called. GlobalOpenTelemetry.set must be "
+ "called only once before any calls to GlobalOpenTelemetry.get. If you are using "
+ "the OpenTelemetrySdk, use OpenTelemetrySdkBuilder.buildAndRegisterGlobal "
+ "instead. Previous invocation set to cause of this exception.",
setGlobalCaller);
}
globalOpenTelemetry = new ObfuscatedOpenTelemetry(openTelemetry);
setGlobalCaller = new Throwable();
}
}
It is really crucial for us to add additional global attributes dynamically in life time of application
The text was updated successfully, but these errors were encountered:
We currently provide a way to do what you're describing via the OtelRumConfig object using its setGlobalAttributes method. You can take a look at this line in the sample app to see how it can be used, although the example there is not exactly what you need, it shows how to prepare it all and make it work. The setGlobalAttributes method can be both static and dynamic, in the example we're making it static as we're passing an already built set of attributes, but in its "dynamic" form you'd need to pass a Supplier instead that would get queried on every new span or log creation, hence you can change its return value at any point during your app runtime which would essentially change your app's attrs dynamically. This is what it should look like:
val config =OtelRumConfig()
.setGlobalAttributes { Attributes.of(stringKey("some_dynamic_key"), "its latest value") }
The lambda can change its returned value at any time making newer spans and logs to use the latest returned attrs.
What this approach does is intercept new spans and logs as they are created and set the provided attrs to them one by one, this is the only way we can have effectively dynamic "global attrs" in OTel as OTel Resources are immutable by design.
Currently, the application is limited in its ability to add global Resource attributes. These attributes can only be set at the start of RUM (Real User Monitoring) sessions. Once the application has begun, there is no mechanism to dynamically add or modify these resource attributes throughout the application's lifetime.
also, there is no possibility to restart the session, because of that line of code:
It is really crucial for us to add additional global attributes dynamically in life time of application
The text was updated successfully, but these errors were encountered: