File: tracer_example.cpp

package info (click to toggle)
dd-opentracing-cpp 1.3.7-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,336 kB
  • sloc: cpp: 44,895; sh: 697; ansic: 27; makefile: 20
file content (23 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <datadog/opentracing.h>
#include <datadog/tags.h>

#include <iostream>
#include <string>

int main(int argc, char* argv[]) {
  datadog::opentracing::TracerOptions options;
  // The environment variable DD_TRACE_AGENT_URL, passed in by docker-compose,
  // will override the "how to connect to the agent" part of `options`.
  auto tracer = datadog::opentracing::makeTracer(options);

  {
    auto span_a = tracer->StartSpan("A");
    span_a->SetTag(datadog::tags::environment, "production");
    span_a->SetTag("tag", 123);
    auto span_b = tracer->StartSpan("B", {opentracing::ChildOf(&span_a->context())});
    span_b->SetTag("tag", "value");
  }

  tracer->Close();
  return 0;
}