Skip to content

Commit b1084ac

Browse files
committed
Add telemetry endpoint.
1 parent 0ca5593 commit b1084ac

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

samples/otlptrace/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ gcloud auth application-default login
2424
```sh
2525
# export necessary OTEL environment variables
2626
export OTEL_RESOURCE_ATTRIBUTES="gcp.project_id=<project-id>"
27-
export OTEL_EXPORTER_OTLP_ENDPOINT=<endpoint>
2827

2928
# from the samples/otlptrace repository
3029
python3 example_grpc.py

samples/otlptrace/example_grpc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@
3636
request = google.auth.transport.requests.Request()
3737
resource = Resource.create(attributes={SERVICE_NAME: "otlp-gcp-grpc-sample"})
3838

39-
auth_metadata_plugin = AuthMetadataPlugin(
40-
credentials=credentials, request=request
41-
)
39+
auth_metadata_plugin = AuthMetadataPlugin(credentials=credentials, request=request)
4240
channel_creds = grpc.composite_channel_credentials(
4341
grpc.ssl_channel_credentials(),
4442
grpc.metadata_call_credentials(auth_metadata_plugin),
4543
)
4644

4745
trace_provider = TracerProvider(resource=resource)
48-
processor = BatchSpanProcessor(OTLPSpanExporter(credentials=channel_creds))
46+
processor = BatchSpanProcessor(
47+
OTLPSpanExporter(
48+
credentials=channel_creds,
49+
endpoint="https://telemetry.googleapis.com:443/v1/traces",
50+
)
51+
)
4952
trace_provider.add_span_processor(processor)
5053
trace.set_tracer_provider(trace_provider)
5154
tracer = trace.get_tracer("my.tracer.name")

samples/otlptrace/example_http.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@
3333
resource = Resource.create(attributes={SERVICE_NAME: "otlp-gcp-http-sample"})
3434

3535
trace_provider = TracerProvider(resource=resource)
36-
processor = BatchSpanProcessor(OTLPSpanExporter(headers=req_headers))
36+
processor = BatchSpanProcessor(
37+
OTLPSpanExporter(
38+
headers=req_headers, endpoint="https://telemetry.googleapis.com:443/v1/traces"
39+
)
40+
)
3741
trace_provider.add_span_processor(processor)
3842
trace.set_tracer_provider(trace_provider)
3943
tracer = trace.get_tracer("my.tracer.name")

0 commit comments

Comments
 (0)