{"slug": "java-spring-boot-opentelemetry-setup-guide", "title": "Java & Spring Boot OpenTelemetry Setup Guide", "summary": "SigNoz released a guide for instrumenting Java and Spring Boot applications with OpenTelemetry to send traces to its observability platform. The guide covers automatic instrumentation via the OpenTelemetry Java agent, configuration for SigNoz Cloud, and deployment steps for Docker and Kubernetes. It aims to help developers monitor application performance using distributed tracing.", "body_md": "This guide walks you through instrumenting your Java or Spring Boot application with OpenTelemetry and sending traces to SigNoz. The Java agent handles most popular libraries and frameworks automatically—Spring, JDBC, HTTP clients, message queues, and more.\n\nPrerequisites\n\n[Java 8+](https://github.com/open-telemetry/opentelemetry-java#requirements)- A SigNoz Cloud account or self-hosted SigNoz instance\n\nSend traces to SigNoz\n\nStep 1. Download the OpenTelemetry Java agent\n\n```\nwget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar\n```\n\nStep 2. Set environment variables\n\n```\nexport OTEL_RESOURCE_ATTRIBUTES=\"service.name=<service-name>,service.version=<service-version>\"\nexport OTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.<region>.signoz.cloud:443\"\nexport OTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<your-ingestion-key>\"\nexport OTEL_METRICS_EXPORTER=\"none\"\nexport OTEL_LOGS_EXPORTER=\"none\"\n```\n\nVerify these values:\n\n`<region>`\n\n: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint).`<your-ingestion-key>`\n\n: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/).`<service-name>`\n\n: A descriptive name for your service (e.g.,`payment-service`\n\n).`<service-version>`\n\n(optional): Your release version, image tag, or git SHA (e.g.,`1.4.2`\n\n,`a01dbef8`\n\n).\n\nSet `service.version`\n\nto a per-build value, not a static string. SigNoz detects a deployment each time this value changes. Common sources:\n\n**Bash / shell**:`service.version=$(git rev-parse --short HEAD)`\n\n**GitHub Actions**:`service.version=${{ github.sha }}`\n\n**GitLab CI**:`service.version=$CI_COMMIT_SHORT_SHA`\n\n**Kubernetes**: inject from your Helm chart image tag or CI variable\n\nStep 3. Run your application\n\nFor Spring Boot applications:\n\n```\njava -javaagent:./opentelemetry-javaagent.jar -jar your-app.jar\n```\n\nFor generic Java applications, you can also pass config as system properties:\n\n```\njava -javaagent:./opentelemetry-javaagent.jar \\\n  -Dotel.service.name=my-service \\\n  -Dotel.exporter.otlp.endpoint=https://ingest.us.signoz.cloud:443 \\\n  -Dotel.exporter.otlp.headers=signoz-ingestion-key=<key> \\\n  -jar your-app.jar\n```\n\nStep 1. Add the agent to your Dockerfile\n\n```\nFROM eclipse-temurin:17-jre\nWORKDIR /app\n\nCOPY target/<my-app>.jar app.jar\n\nRUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar\n\nENTRYPOINT [\"java\", \"-javaagent:/app/opentelemetry-javaagent.jar\", \"-jar\", \"app.jar\"]\n```\n\nStep 2. Deploy to Kubernetes\n\nAdd these environment variables to your deployment manifest:\n\n```\nenv:\n- name: OTEL_RESOURCE_ATTRIBUTES\n  value: 'service.name=<service-name>,service.version=<service-version>'\n- name: OTEL_EXPORTER_OTLP_ENDPOINT\n  value: 'https://ingest.<region>.signoz.cloud:443'\n- name: OTEL_EXPORTER_OTLP_HEADERS\n  value: 'signoz-ingestion-key=<your-ingestion-key>'\n- name: OTEL_METRICS_EXPORTER\n  value: 'none'\n- name: OTEL_LOGS_EXPORTER\n  value: 'none'\n```\n\nVerify these values:\n\n`<region>`\n\n: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint).`<your-ingestion-key>`\n\n: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/).`<service-name>`\n\n: A descriptive name for your service (e.g.,`payment-service`\n\n).`<service-version>`\n\n(optional): Your release version, image tag, or git SHA (e.g.,`1.4.2`\n\n,`a01dbef8`\n\n).\n\nSet `service.version`\n\nto a per-build value, not a static string. SigNoz detects a deployment each time this value changes. Common sources:\n\n**Bash / shell**:`service.version=$(git rev-parse --short HEAD)`\n\n**GitHub Actions**:`service.version=${{ github.sha }}`\n\n**GitLab CI**:`service.version=$CI_COMMIT_SHORT_SHA`\n\n**Kubernetes**: inject from your Helm chart image tag or CI variable\n\nThe [OpenTelemetry Operator](https://signoz.io/docs/opentelemetry-collection-agents/k8s/otel-operator/overview/) auto-injects the Java agent into your pods without modifying your container image.\n\nStep 1. Set up the OpenTelemetry Operator\n\nInstall the Operator and Collector following the [K8s OTel Operator installation guide](https://signoz.io/docs/opentelemetry-collection-agents/k8s/otel-operator/install/).\n\nStep 2. Create the Instrumentation resource\n\nCreate `instrumentation.yaml`\n\nto configure Java auto-instrumentation:\n\n```\napiVersion: opentelemetry.io/v1alpha1\nkind: Instrumentation\nmetadata:\n  name: java-instrumentation\nspec:\n  exporter:\n    endpoint: http://otel-collector-collector:4318\n  propagators:\n    - tracecontext\n    - baggage\n  env:\n    - name: OTEL_METRICS_EXPORTER\n      value: \"none\"\n    - name: OTEL_LOGS_EXPORTER\n      value: \"none\"\n  java:\n    image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-java:latest\n```\n\nDeploy this resource to your cluster.\n\nStep 3. Add annotations to your deployment\n\nAdd these annotations to your pod template's `metadata.annotations`\n\n:\n\n```\ninstrumentation.opentelemetry.io/inject-java: \"true\"\nresource.opentelemetry.io/service.name: \"<service-name>\"\nresource.opentelemetry.io/service.version: \"<service-version>\"\n```\n\nVerify these values:\n\n`<service-name>`\n\n: A descriptive name for your service (e.g.,`payment-service`\n\n).`<service-version>`\n\n(optional): Your release version, image tag, or git SHA (e.g.,`1.4.2`\n\n,`a01dbef8`\n\n).\n\nSet `service.version`\n\nto a per-build value, not a static string. SigNoz detects a deployment each time this value changes. Common sources:\n\n**Bash / shell**:`service.version=$(git rev-parse --short HEAD)`\n\n**GitHub Actions**:`service.version=${{ github.sha }}`\n\n**GitLab CI**:`service.version=$CI_COMMIT_SHORT_SHA`\n\n**Kubernetes**: inject from your Helm chart image tag or CI variable\n\nStep 1. Download the OpenTelemetry Java agent\n\n```\nInvoke-WebRequest -Uri \"https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar\" -OutFile \"opentelemetry-javaagent.jar\"\n```\n\nStep 2. Set environment variables\n\n```\n$env:OTEL_RESOURCE_ATTRIBUTES = \"service.name=<service-name>,service.version=<service-version>\"\n$env:OTEL_EXPORTER_OTLP_ENDPOINT = \"https://ingest.<region>.signoz.cloud:443\"\n$env:OTEL_EXPORTER_OTLP_HEADERS = \"signoz-ingestion-key=<your-ingestion-key>\"\n$env:OTEL_METRICS_EXPORTER = \"none\"\n$env:OTEL_LOGS_EXPORTER = \"none\"\n```\n\nVerify these values:\n\n`<region>`\n\n: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint).`<your-ingestion-key>`\n\n: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/).`<service-name>`\n\n: A descriptive name for your service (e.g.,`payment-service`\n\n).`<service-version>`\n\n(optional): Your release version, image tag, or git SHA (e.g.,`1.4.2`\n\n,`a01dbef8`\n\n).\n\nSet `service.version`\n\nto a per-build value, not a static string. SigNoz detects a deployment each time this value changes. Common sources:\n\n**Bash / shell**:`service.version=$(git rev-parse --short HEAD)`\n\n**GitHub Actions**:`service.version=${{ github.sha }}`\n\n**GitLab CI**:`service.version=$CI_COMMIT_SHORT_SHA`\n\n**Kubernetes**: inject from your Helm chart image tag or CI variable\n\nStep 3. Run your application\n\nFor Spring Boot applications:\n\n```\njava -javaagent:.\\opentelemetry-javaagent.jar -jar your-app.jar\n```\n\nFor generic Java applications, you can also pass config as system properties:\n\n```\njava -javaagent:.\\opentelemetry-javaagent.jar `\n  -Dotel.service.name=my-service `\n  -Dotel.exporter.otlp.endpoint=https://ingest.us.signoz.cloud:443 `\n  -Dotel.exporter.otlp.headers=signoz-ingestion-key=<key> `\n  -jar your-app.jar\n```\n\nStep 1. Add the agent to your Dockerfile\n\n```\nFROM eclipse-temurin:17-jre\nWORKDIR /app\n\nCOPY target/<my-app>.jar app.jar\n\nRUN wget https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar -O opentelemetry-javaagent.jar\n\nENV OTEL_RESOURCE_ATTRIBUTES=\"service.name=<service-name>,service.version=<service-version>\"\nENV OTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.<region>.signoz.cloud:443\"\nENV OTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<your-ingestion-key>\"\nENV OTEL_METRICS_EXPORTER=\"none\"\nENV OTEL_LOGS_EXPORTER=\"none\"\n\nENTRYPOINT [\"java\", \"-javaagent:/app/opentelemetry-javaagent.jar\", \"-jar\", \"app.jar\"]\n```\n\nVerify these values:\n\n`<region>`\n\n: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint).`<your-ingestion-key>`\n\n: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/).`<service-name>`\n\n: A descriptive name for your service (e.g.,`payment-service`\n\n).`<service-version>`\n\n(optional): Your release version, image tag, or git SHA (e.g.,`1.4.2`\n\n,`a01dbef8`\n\n).\n\nSet `service.version`\n\nto a per-build value, not a static string. SigNoz detects a deployment each time this value changes. Common sources:\n\n**Bash / shell**:`service.version=$(git rev-parse --short HEAD)`\n\n**GitHub Actions**:`service.version=${{ github.sha }}`\n\n**GitLab CI**:`service.version=$CI_COMMIT_SHORT_SHA`\n\n**Kubernetes**: inject from your Helm chart image tag or CI variable\n\nStep 2. Build and run\n\n```\ndocker build -t my-java-app .\ndocker run -p 8080:8080 my-java-app\n```\n\nOr pass environment variables at runtime:\n\n```\ndocker run -p 8080:8080 \\\n  -e OTEL_RESOURCE_ATTRIBUTES=\"service.name=my-service\" \\\n  -e OTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.us.signoz.cloud:443\" \\\n  -e OTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<key>\" \\\n  -e OTEL_METRICS_EXPORTER=\"none\" \\\n  -e OTEL_LOGS_EXPORTER=\"none\" \\\n  my-java-app\n```\n\nValidate\n\nWith your application running, verify traces are being sent to SigNoz:\n\n- Make a few requests to your application endpoints.\n- In SigNoz, open the\n**Services** tab and click**Refresh**. Your application should appear. - Go to the\n**Traces** tab to see your application's traces.\n\nTroubleshooting\n\n[Troubleshooting](#troubleshooting)\n\nTraces not showing up in SigNoz?\n\n**Check environment variables:**\n\n```\necho $OTEL_EXPORTER_OTLP_ENDPOINT\necho $OTEL_RESOURCE_ATTRIBUTES\n```\n\n**Enable debug logging:**\n\n```\nOTEL_LOG_LEVEL=debug java -javaagent:./opentelemetry-javaagent.jar -jar app.jar\n```\n\nLook for span output in stdout. If spans appear locally but not in SigNoz, check your endpoint URL and ingestion key.\n\n**Test connectivity:**\n\n```\ncurl -v https://ingest.<region>.signoz.cloud:443/v1/traces\n```\n\nAgent not attaching?\n\nMake sure `-javaagent`\n\ncomes before `-jar`\n\n:\n\n```\n# Correct\njava -javaagent:./agent.jar -jar app.jar\n\n# Wrong - agent flag after -jar is ignored\njava -jar app.jar -javaagent:./agent.jar\n```\n\nConfiguring the agent (Optional)\n\n[Configuring the agent (Optional)](#configuring-the-agent-optional)\n\nWhat can you configure?\n\nThe Java agent auto-instruments most libraries out of the box. Configuration lets you fine-tune what gets captured and how traces are exported.\n\nWhy configure?\n\n**Reduce noise**— Disable instrumentation for internal health checks or chatty libraries** Control costs**— Sample a percentage of traces instead of capturing everything** Add context**— Tag traces with environment, version, or team info for easier filtering\n\nCommon options\n\n**Disable specific instrumentations:**\n\n```\n-Dotel.instrumentation.jdbc-datasource.enabled=false\n```\n\nSome instrumentations are disabled by default because they're noisy:\n\n`jdbc-datasource`\n\n— creates spans for every`DataSource.getConnection()`\n\ncall`dropwizard-metrics`\n\n— limited attribute support in Dropwizard's metrics API\n\n**Sample traces:**\n\n```\nexport OTEL_TRACES_SAMPLER=parentbased_traceidratio\nexport OTEL_TRACES_SAMPLER_ARG=0.1  # Sample 10% of traces\n```\n\n**Add resource attributes:**\n\n```\nexport OTEL_RESOURCE_ATTRIBUTES=\"service.name=my-app,deployment.environment=production,service.version=1.2.3\"\n```\n\nSee the [full configuration reference](https://opentelemetry.io/docs/languages/java/automatic/agent-config/) for all available options.\n\nSetup OpenTelemetry Collector (Optional)\n\n[Setup OpenTelemetry Collector (Optional)](#setup-opentelemetry-collector-optional)\n\nWhat is the OpenTelemetry Collector?\n\nThe Collector sits between your app and SigNoz. Your app sends traces to the Collector, which then forwards them to SigNoz.\n\nWhy use it?\n\n**Filter and transform**- Drop noisy traces or redact sensitive data before it leaves your network** Reduce app overhead**- Let the Collector handle batching, retries, and compression** Add metadata**- Automatically tag traces with Kubernetes pod info, cloud region, etc.** Multi-backend**- Send to multiple observability tools without changing your app\n\nSee [Switch from direct export to Collector](https://signoz.io/docs/opentelemetry-collection-agents/opentelemetry-collector/switch-to-collector/) for setup instructions.\n\nNext steps\n\n[Add manual instrumentation](https://signoz.io/docs/instrumentation/java/manual-instrumentation/)for custom spans and business context- Send\n[metrics](https://signoz.io/docs/metrics-management/send-metrics/applications/opentelemetry-java/)and[logs](https://signoz.io/docs/logs-management/send-logs/java-logs/)from your Java application for complete observability [Set up alerts](https://signoz.io/docs/setup-alerts-notification/)for your Java application- For a framework-focused walkthrough, our\n[Spring Boot OpenTelemetry tutorial](https://signoz.io/blog/opentelemetry-spring-boot/)covers instrumentation patterns specific to Spring alongside the agent setup above.\n\n**Sample applications**:", "url": "https://wpnews.pro/news/java-spring-boot-opentelemetry-setup-guide", "canonical_source": "https://signoz.io/docs/instrumentation/java/opentelemetry-java", "published_at": "2026-06-17 00:00:00+00:00", "updated_at": "2026-06-18 06:24:32.147814+00:00", "lang": "en", "topics": ["developer-tools", "artificial-intelligence"], "entities": ["SigNoz", "OpenTelemetry", "Java", "Spring Boot", "Kubernetes", "Docker", "GitHub", "GitLab"], "alternates": {"html": "https://wpnews.pro/news/java-spring-boot-opentelemetry-setup-guide", "markdown": "https://wpnews.pro/news/java-spring-boot-opentelemetry-setup-guide.md", "text": "https://wpnews.pro/news/java-spring-boot-opentelemetry-setup-guide.txt", "jsonld": "https://wpnews.pro/news/java-spring-boot-opentelemetry-setup-guide.jsonld"}}