-
Notifications
You must be signed in to change notification settings - Fork 14
Fix Otel Support: use agent sdk when there is one #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| if (sdk == null) { | ||
| synchronized (FunctionsOpenTelemetry.class) { | ||
| if (initialized) { | ||
| return; // Fast path - no synchronization needed after initialization |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious, why we need initialized parameter fir thread safety, why can't globelOtel can be used.
Concern I have is there are two volatile variables to support same functionality.
`public static void initialize() {
if (globelOtel!= null) {
return; // Fast path
}
synchronized (FunctionsOpenTelemetry.class) {
if (globelOtel!= null) {
return; // Double-check after acquiring lock
}
io.opentelemetry.api.OpenTelemetry global = GlobalOpenTelemetry.get();
if (isNoOp(global)) {
LOGGER.info("No global OpenTelemetry found; initializing SDK.");
globelOtel= buildSdk();
} else {
LOGGER.info("GlobalOpenTelemetry already set; using existing instance.");
globelOtel= global;
}
}
}
`
| * Ensures initialization has occurred. | ||
| */ | ||
| private static void ensureInitialized() { | ||
| if (!initialized) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (globelOtel!= null)
| * Returns the priority order for this resource provider. | ||
| */ | ||
| @Override | ||
| public int order() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the order()?
…sn't have to bring them in
This pull request introduces several improvements and refactorings to the OpenTelemetry integration for Azure Functions in Java. The main focus is on making the SDK initialization more robust and agent-agnostic, improving resource detection documentation and logic, and updating test dependencies and build plugins for better compatibility and reliability.
SDK Initialization and Robustness
FunctionsOpenTelemetryto support agent-agnostic initialization, caching the global OpenTelemetry instance, and ensuring thread-safe, idempotent setup. Initialization now works seamlessly with or without an OpenTelemetry agent, and avoids unnecessary global registration. [1] [2]buildAndRegisterGlobalfor fallback scenarios.Resource Detection Documentation and Logic
FunctionsResourceDetectorto document the resource detection process, its modes (local vs. Azure-hosted), and the mapping to OpenTelemetry semantic conventions. Attribute and environment variable documentation was made more explicit.API Usability and Convenience
FunctionsOpenTelemetry, including a default tracer name and overloads for trace context usage.Build and Test Dependency Updates
1.1.0and downgradedjunit.jupiter.versionto5.9.3for compatibility. [1] [2]junit-jupiter-engineandjunit-platform-launchertest dependencies, and introduced themaven-surefire-pluginfor improved test execution. [1] [2]