@@ -129,69 +129,84 @@ The way that you instrument your application to use OpenTelemetry depends on you
129
129
::: zone-end
130
130
::: zone pivot="programming-language-java"
131
131
132
- ### 1 Add the required libraries
132
+ ### Step 1 – Add the required libraries
133
133
134
- 1. **Core bridge (always)** – enables OpenTelemetry inside the Java worker
134
+ **Core bridge** (always) – enables OpenTelemetry inside the Java worker
135
135
136
- **Maven**
136
+ <details open>
137
+ <summary>Maven</summary>
137
138
138
- ```xml
139
- <dependency>
140
- <groupId>com.microsoft.azure.functions</groupId>
141
- <artifactId>azure-functions-java-opentelemetry</artifactId>
142
- <version>1.0.0</version>
143
- </dependency>
144
- ```
139
+ ```xml
140
+ <dependency>
141
+ <groupId>com.microsoft.azure.functions</groupId>
142
+ <artifactId>azure-functions-java-opentelemetry</artifactId>
143
+ <version>1.0.0</version>
144
+ </dependency>
145
+ ```
146
+
147
+ </details >
148
+
149
+ <details >
150
+ <summary >Gradle (Kotlin DSL)</summary >
151
+
152
+ ``` kotlin
153
+ implementation(" com.microsoft.azure.functions:azure-functions-java-opentelemetry:1.0.0" )
154
+ ```
155
+
156
+ </details >
145
157
146
- ** Gradle (Kotlin DSL) **
158
+ ** Application Insights exporter ** (optional) – add only if you plan to send data to AI
147
159
148
- ``` kotlin
149
- implementation(" com.microsoft.azure.functions:azure-functions-java-opentelemetry:1.0.0" )
150
- ```
160
+ <details >
161
+ <summary >Maven</summary >
151
162
152
- 2 . ** Application Insights exporter (optional)** – only if you want to send data to AI
163
+ ``` xml
164
+ <dependency >
165
+ <groupId >com.azure</groupId >
166
+ <artifactId >azure-monitor-opentelemetry-autoconfigure</artifactId >
167
+ <version >1.2.0</version >
168
+ </dependency >
169
+ ```
153
170
154
- ** Maven **
171
+ </ details >
155
172
156
- ``` xml
157
- <dependency >
158
- <groupId >com.azure</groupId >
159
- <artifactId >azure-monitor-opentelemetry-autoconfigure</artifactId >
160
- <version >1.2.0</version >
161
- </dependency >
162
- ```
173
+ <details >
174
+ <summary >Gradle (Kotlin DSL)</summary >
163
175
164
- ** Gradle (Kotlin DSL)**
176
+ ``` kotlin
177
+ implementation(" com.azure:azure-monitor-opentelemetry-autoconfigure:1.2.0" )
178
+ ```
165
179
166
- ``` kotlin
167
- implementation(" com.azure:azure-monitor-opentelemetry-autoconfigure:1.2.0" )
168
- ```
180
+ </details >
169
181
170
- > The bridge locates ` AzureMonitorAutoConfigure ` by reflection; if this dependency is absent , it just skips the AI exporter.
182
+ > The bridge looks for ` AzureMonitorAutoConfigure ` by reflection; if this dependency isn’t present , it simply skips the AI exporter.
171
183
172
184
---
173
185
174
- ### 2 Add application settings
186
+ ### Step 2 – Add application settings
187
+
188
+ Set this flag ** in every Java Functions app that uses the bridge** , even if you export only to OTLP:
175
189
176
190
``` text
177
191
JAVA_APPLICATIONINSIGHTS_ENABLE_TELEMETRY=true
178
192
```
179
193
180
- Setting this flag ** enables a worker capability that tells the Functions host to stop forwarding its own logs and let the Java worker stream OpenTelemetry records instead , preventing duplicate log entries.**
194
+ This capability tells the Functions host to let the Java worker stream OpenTelemetry logs directly , preventing duplicate host-level entries.
181
195
182
- Other settings:
196
+ Additional settings:
183
197
184
- | Purpose | Name | Example |
185
- | ------------------------------- | --------------------------------------- | -------------------------------------------------- |
186
- | Application Insights connection | ` APPLICATIONINSIGHTS_CONNECTION_STRING ` | ` InstrumentationKey=…;IngestionEndpoint=https://… ` |
187
- | OTLP export | ` OTEL_EXPORTER_OTLP_ENDPOINT ` | ` https://otlp.example.com:4318 ` |
188
- | | ` OTEL_EXPORTER_OTLP_HEADERS ` (optional) | ` api-key=abcd1234 ` |
198
+ * ** Application Insights**
199
+ ` APPLICATIONINSIGHTS_CONNECTION_STRING=InstrumentationKey=...;IngestionEndpoint=https://... `
189
200
190
- If both AI * and* OTLP variables are present, telemetry is sent to ** both** back-ends.
201
+ * ** OTLP export**
202
+ ` OTEL_EXPORTER_OTLP_ENDPOINT=https://otlp.example.com:4318 `
203
+ ` OTEL_EXPORTER_OTLP_HEADERS=api-key=abcd1234 ` (optional)
204
+
205
+ If both AI * and* OTLP variables are present, telemetry flows to ** both** back-ends.
191
206
192
207
---
193
208
194
- ### 3 (Optional) create custom spans
209
+ ### Step 3 – (Optional) create custom spans
195
210
196
211
``` java
197
212
import com.microsoft.azure.functions.opentelemetry.FunctionsOpenTelemetry ;
@@ -200,34 +215,36 @@ import io.opentelemetry.api.trace.SpanKind;
200
215
import io.opentelemetry.context.Scope ;
201
216
202
217
Span span = FunctionsOpenTelemetry . startSpan(
203
- " com.contoso.PaymentFunction" , // tracer
204
- " validateCharge" , // span
218
+ " com.contoso.PaymentFunction" , // tracer name
219
+ " validateCharge" , // span name
205
220
null , // parent = current context
206
221
SpanKind . INTERNAL );
207
222
208
223
try (Scope ignored = span. makeCurrent()) {
209
- // your business logic here
224
+ // business logic here
210
225
} finally {
211
226
span. end();
212
227
}
213
228
```
214
229
215
- Custom spans inherit the same resource attributes and exporters configured by the bridge.
230
+ Custom spans inherit all resource attributes and exporters configured by the bridge.
216
231
217
232
---
218
233
219
- ### 4 Local development & testing tips
234
+ ### Step 4 – Local development and testing tips
220
235
221
- * When not running in Azure, the resource detector defaults ` service.name ` to ` java-function-app ` .
222
- * Silence telemetry during unit tests with JVM flags :
236
+ * Outside Azure, the resource detector defaults ` service.name ` to ` java-function-app ` .
237
+ * ** Java Virtual Machine (JVM) ** flags to silence telemetry during unit tests:
223
238
224
239
``` text
225
240
-Dotel.traces.exporter=none
226
241
-Dotel.metrics.exporter=none
227
242
-Dotel.logs.exporter=none
228
243
```
229
- * No manual registration is required—` OpenTelemetryInvocationMiddleware ` is auto-discovered by the Java worker.
244
+ * You don’t need to register anything manually—the Java worker ** autodiscovers** ` OpenTelemetryInvocationMiddleware ` .
245
+
230
246
::: zone-end
247
+
231
248
::: zone pivot="programming-language-javascript,programming-language-typescript"
232
249
1 . Install these npm packages in your project:
233
250
0 commit comments