Skip to content

Commit 4b26c15

Browse files
author
Lingling Peng
committed
add an additional section; restore section for jaeger
1 parent 2acb426 commit 4b26c15

File tree

1 file changed

+54
-4
lines changed

1 file changed

+54
-4
lines changed

README.md

Lines changed: 54 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,55 @@ OpenTelemetry (OTEL)
280280

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

283+
284+
### Exporting Synapse Client Traces to Jaeger for developers
285+
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.
286+
287+
#### Running the jaeger docker container
288+
Start a docker container with the following options:
289+
```
290+
docker run --name jaeger \
291+
-e COLLECTOR_OTLP_ENABLED=true \
292+
-p 16686:16686 \
293+
-p 4318:4318 \
294+
jaegertracing/all-in-one:latest
295+
```
296+
Explanation of ports:
297+
* `4318` HTTP port for OTLP data collection
298+
* `16686` Jaeger UI for visualizing traces
299+
300+
Once the docker container is running you can access the Jaeger UI via: `http://localhost:16686`
301+
302+
#### Environment Variable Configuration
303+
304+
By default, the OTEL exporter sends trace data to `http://localhost:4318/v1/traces`. You can customize the behavior through environment variables:
305+
306+
* `OTEL_SERVICE_NAME`: Defines a unique identifier for your application or service in telemetry data (defaults to 'synapseclient'). Set this to a descriptive name that represents your specific implementation, making it easier to filter and analyze traces in your monitoring system.
307+
* `OTEL_EXPORTER_OTLP_ENDPOINT`: Specifies the destination URL for sending telemetry data (defaults to 'http://localhost:4318'). Configure this to direct data to your preferred OpenTelemetry collector or monitoring service.
308+
* `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.
309+
* `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.
310+
* `OTEL_EXPORTER_OTLP_HEADERS`: Configures authentication and metadata for telemetry exports. Use this to add API keys, authentication tokens, or custom metadata when sending traces to secured collectors or third-party monitoring services.
311+
312+
313+
#### Enabling OpenTelemetry in your code
314+
To enable OpenTelemetry with the Synapse Python client, simply call the
315+
`enable_open_telemetry()` method on the Synapse class. Additionally you can access an
316+
instance of the OpenTelemetry tracer via the `get_tracer()` call. This will allow you
317+
to create new spans for your code.
318+
319+
```python
320+
import synapseclient
321+
322+
# Enable OpenTelemetry with default settings
323+
synapseclient.Synapse.enable_open_telemetry()
324+
tracer = synapseclient.Synapse.get_tracer()
325+
326+
# Then create and use the Synapse client as usual
327+
with tracer.start_as_current_span("my_function_span"):
328+
syn = synapseclient.Synapse()
329+
syn.login(authToken='auth_token')
330+
```
331+
283332
### Exporting Synapse Client Traces to SigNoz Cloud for developers
284333

285334
#### Prerequisites
@@ -303,8 +352,6 @@ Explanation of both required and optional environment variables:
303352
* `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.
304353

305354
#### Enabling OpenTelemetry in your code
306-
You can copy `.env.example` file to `.env` and fill in the values as needed
307-
308355
To enable OpenTelemetry with the Synapse Python client, simply call the
309356
`enable_open_telemetry()` method on the Synapse class. Additionally you can access an
310357
instance of the OpenTelemetry tracer via the `get_tracer()` call. This will allow you
@@ -314,8 +361,11 @@ to create new spans for your code.
314361
import synapseclient
315362
from dotenv import load_dotenv
316363

317-
# load environment variables from .env file
318-
load_dotenv()
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"
319369

320370
# Enable OpenTelemetry with default settings
321371
synapseclient.Synapse.enable_open_telemetry()

0 commit comments

Comments
 (0)