Skip to content

Instantly share code, notes, and snippets.

@thomasdesr
Created December 24, 2020 02:51
Show Gist options
  • Save thomasdesr/08849445953715f38cf6d29d17b00adf to your computer and use it in GitHub Desktop.
Save thomasdesr/08849445953715f38cf6d29d17b00adf to your computer and use it in GitHub Desktop.
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import (
ConsoleSpanExporter,
SimpleExportSpanProcessor,
)
from opentelemetry.instrumentation.botocore import BotocoreInstrumentor
trace.set_tracer_provider(TracerProvider())
trace.get_tracer_provider().add_span_processor(
SimpleExportSpanProcessor(ConsoleSpanExporter())
)
BotocoreInstrumentor().instrument()
import boto3
sts = boto3.client("sts")
sts.get_caller_identity()
$ python tmp.py
{
"name": "sts",
"context": {
"trace_id": "0x98e82db3da6061ecf27ff37124eb1529",
"span_id": "0xee82af410a24060e",
"trace_state": "{}"
},
"kind": "SpanKind.CLIENT",
"parent_id": null,
"start_time": "2020-12-24T02:48:10.826740Z",
"end_time": "2020-12-24T02:48:11.035842Z",
"status": {
"status_code": "UNSET"
},
"attributes": {
"aws.operation": "GetCallerIdentity",
"aws.region": "us-west-2",
"aws.service": "sts",
"aws.request_id": "3dca3b9c-42ee-4b95-824c-220aac1fcbab",
"aws.retry_attempts": 0,
"http.status_code": 200
},
"events": [],
"links": [],
"resource": {
"telemetry.sdk.language": "python",
"telemetry.sdk.name": "opentelemetry",
"telemetry.sdk.version": "0.17.dev0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment