Skip to content

Instantly share code, notes, and snippets.

@prognant
Created May 19, 2022 15:59
Show Gist options
  • Save prognant/de1a1b842f4dcd41c1efff8d4ffbe8ad to your computer and use it in GitHub Desktop.
Save prognant/de1a1b842f4dcd41c1efff8d4ffbe8ad to your computer and use it in GitHub Desktop.
dummy_trace_gen.py / need pip install ddtrace
#######
import os
from ddtrace import tracer
tracer.configure(
hostname="127.0.0.1",
port="8126",
)
top_level_tags = {
"foo": "bar",
"env": "prognant-dev",
}
tracer.set_tags(top_level_tags)
# Top level span
span = tracer.trace("operations.of.interest", service="trace-test-app")
span.set_tag("env", "prognant-dev")
span.set_tag("numeric", 1.234)
span.context.sampling_priority = 10
def nest_span(tracer, n):
if n == 0:
return
with tracer.trace("child_%d"%n, service='trace-test-app'):
time.sleep(0.1)
nest_span(tracer, n - 1)
for i in range(2):
import time
span
nest_span(tracer, 10)
span.finish()
#### dd agent config setting
apm_config.apm_dd_url: http://localhost:8081
#### Vector simple config
sources:
dd_agent:
type: datadog_agent
address: "[::]:8081"
multiple_outputs: true
trace_proto: v1v2
sinks:
dd_trace:
type: datadog_traces
inputs:
- dd_agent.traces
default_api_key: "A KEY"
dbg:
type: console
encoding:
codec: json
inputs:
- dd_agent.traces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment