Skip to content

Commit 5f31ab7

Browse files
authored
Merge pull request #1259 from Sage-Bionetworks/fix-otel-doc
[Technical debt]: Fix documentation for running OTEL trace export to SigNoz locally
2 parents 41b0c30 + 992ef42 commit 5f31ab7

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

README.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,8 @@ OpenTelemetry (OTEL)
280280

281281
Read more about OpenTelemetry in Python [here](https://opentelemetry.io/docs/instrumentation/python/)
282282

283-
### Quick-start
283+
284+
### Exporting Synapse Client Traces to Jaeger for developers
284285
The following shows an example of setting up [jaegertracing](https://www.jaegertracing.io/docs/1.50/deployment/#all-in-one) via docker and executing a simple python script that implements the Synapse Python client.
285286

286287
#### Running the jaeger docker container
@@ -328,6 +329,54 @@ with tracer.start_as_current_span("my_function_span"):
328329
syn.login(authToken='auth_token')
329330
```
330331

332+
### Exporting Synapse Client Traces to SigNoz Cloud for developers
333+
334+
#### Prerequisites
335+
1. Create an account and obtain access to Signoz Cloud.
336+
2. Create an ingestion key by following the step [here](https://signoz.io/docs/ingestion/signoz-cloud/keys/).
337+
338+
#### Environment Variable Configuration
339+
The following environment variables are required to be set:
340+
- `OTEL_EXPORTER_OTLP_HEADERS`: `signoz-ingestion-key=<key>`
341+
- `OTEL_EXPORTER_OTLP_ENDPOINT`: `https://ingest.us.signoz.cloud`
342+
- `OTEL_SERVICE_NAME`: `your-service-name`
343+
344+
Explanation of both required and optional environment variables:
345+
##### Required
346+
* `OTEL_EXPORTER_OTLP_ENDPOINT`: The OTLP endpoint to which telemetry is exported.
347+
* `OTEL_EXPORTER_OTLP_HEADERS`: Authentication/metadata for exports (e.g., API keys, tokens). For SigNoz, use `signoz-ingestion-key=<key>`.
348+
349+
##### Optional
350+
* `OTEL_SERVICE_NAME`: Unique identifier for your app/service in telemetry data (defaults to synapseclient). Use a descriptive name so you can easily filter and analyze traces per service.
351+
* `OTEL_DEBUG_CONSOLE`: Controls local visibility of telemetry data. Set to 'true' to output trace information to the console, which is useful for development and troubleshooting without an external collector.
352+
* `OTEL_SERVICE_INSTANCE_ID`: Distinguishes between multiple instances of the same service (e.g., 'prod', 'development', 'local'). This helps identify which specific deployment or environment generated particular traces.
353+
354+
#### Enabling OpenTelemetry in your code
355+
To enable OpenTelemetry with the Synapse Python client, simply call the
356+
`enable_open_telemetry()` method on the Synapse class. Additionally you can access an
357+
instance of the OpenTelemetry tracer via the `get_tracer()` call. This will allow you
358+
to create new spans for your code.
359+
360+
```python
361+
import synapseclient
362+
from dotenv import load_dotenv
363+
364+
# Set environment variables
365+
os.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = "https://ingest.us.signoz.cloud"
366+
os.environ["OTEL_EXPORTER_OTLP_HEADERS"] = "signoz-ingestion-key=<your key>"
367+
os.environ["OTEL_SERVICE_NAME"] = "your-service-name"
368+
os.environ["OTEL_SERVICE_INSTANCE_ID"] = "local"
369+
370+
# Enable OpenTelemetry with default settings
371+
synapseclient.Synapse.enable_open_telemetry()
372+
tracer = synapseclient.Synapse.get_tracer()
373+
374+
# Then create and use the Synapse client as usual
375+
with tracer.start_as_current_span("my_function_span"):
376+
syn = synapseclient.Synapse()
377+
syn.login(authToken='auth_token')
378+
```
379+
331380
#### Advanced Configuration
332381

333382
You can pass additional resource attributes to `enable_open_telemetry()`:

0 commit comments

Comments
 (0)