Skip to content

Commit

Permalink
updated the java azure function example
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitchsplunk committed Dec 6, 2024
1 parent 777e4af commit 1cccb71
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
11 changes: 6 additions & 5 deletions instrumentation/java/azure-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ used for local testing:
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "java",
"APPLICATIONINSIGHTS_ENABLE_AGENT": "true",
"OTEL_SERVICE_NAME": "azure-function-java-opentelemetry-example",
"DEPLOYMENT_ENVIRONMENT": "test",
"SPLUNK_REALM": "<Splunk Realm i.e. us0, us1, eu0, etc. >",
Expand All @@ -184,8 +183,6 @@ used for local testing:
}
````

Note that we also set APPLICATIONINSIGHTS_ENABLE_AGENT to "true" to ensure the log4j logs appear in App Insights.

## Build and Deploy

Open the following project using Visual Studio Code:
Expand All @@ -212,7 +209,7 @@ In my example, I created a deployment slot named "test".
### Set Environment Variables

To allow OpenTelemetry to send trace data to Splunk Observability Cloud,
we need to set the APPLICATIONINSIGHTS_ENABLE_AGENT, OTEL_SERVICE_NAME, DEPLOYMENT_ENVIRONMENT, SPLUNK_REALM and SPLUNK_ACCESS_TOKEN environment variables for our Azure Function App:
we need to set the `OTEL_SERVICE_NAME`, `DEPLOYMENT_ENVIRONMENT`, `SPLUNK_REALM` and `SPLUNK_ACCESS_TOKEN` environment variables for our Azure Function App:

![Environment Variables](./images/env-vars.png)

Expand Down Expand Up @@ -267,4 +264,8 @@ using the custom logging changes described above:
````

This will ensure full correlation between traces generated by the OpenTelemetry instrumentation
with metrics and logs.
with metrics and logs.

We can see that the log messages Application Insights also include the trace context:

![App Insights Logs](./images/app-insights-logs.png)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</Console>
</Appenders>
<Loggers>
<Logger name="com.azure.core" level="error" additivity="true">
<Logger name="com.azure.core" level="info" additivity="true">
<appender-ref ref="console" />
</Logger>
<Root level="info" additivity="false">
Expand Down

0 comments on commit 1cccb71

Please sign in to comment.