-
Notifications
You must be signed in to change notification settings - Fork 15
Allow setting internal tags and expose numeric tags as metrics #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
BenchmarksBenchmark execution time: 2024-04-15 08:09:40 Comparing candidate commit 98fa63c in PR branch Found 0 performance improvements and 0 performance regressions! Performance is the same for 1 metrics, 0 unstable metrics. |
|
I don't know much about metrics. Until then, is there a way to test/view metrics sent to the Agent in the Datadog UI? In other words, how did you test it and how can I? |
|
"metrics" is a word used to describe floating point valued ( They're sent as "metrics" (along with normal tags, called "meta") in the messagepack/protobuf message sent to the Agent and then to Intake: https://github.com/DataDog/datadog-agent/blob/74fae3f4afeb77720e6584cccbbe853b5c9d677d/pkg/proto/datadog/trace/span.proto#L53-L55 It has nothing to do with metrics. "Metrics" is a terrible name. You can imagine how, historically, someone might have imagined it would be used for metrics, but it is not. It is an open question which tags belong in "meta" (strings) and which tags belong in "metrics." There is some disagreement, e.g. for My opinion is that tags are strings, and "metrics" is a ill-conceived attempt at optimization, or an artifact of some constraint imposed by some library in the Agent or Intake. There's my unsolicited opinion. :) edit: Talk to Doug Hawkins for more background. |
| if (!tags::is_internal(key)) { | ||
| tags.insert_or_assign(key, value); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want any user of the library to be able to set internal tags? Same question in span.cpp.
If Datadog has an internal client who wishes to have special access to the span representation, then consider adding an API specific to that use case, and document it as such.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure there is much value in forbidding internal tags, however I'm open to the idea of separating the *_tag and *_metric methods into *_internal_tag and *internal_metric if that makes it more palatable.
This is what I used to test it: #include <datadog/span_config.h>
#include <datadog/tracer.h>
#include <datadog/tracer_config.h>
int main() {
datadog::tracing::TracerConfig config;
config.service = "test-service";
config.environment = "staging";
const auto validated_config = datadog::tracing::finalize_config(config);
if (!validated_config) {
return 1;
}
datadog::tracing::Tracer tracer{*validated_config};
datadog::tracing::SpanConfig options;
options.name = "metric-span";
datadog::tracing::Span parent = tracer.create_span(options);
parent.set_metric("metric", 10.0);
return 0;
}You'll need to have the agent running with the relevant API key, but you should be able to see a span containing the metric: |
The reason I'm introducing metrics is for internal use, i.e. appsec needs to be able to send metrics / numeric tags. Note that internal in this case doesn't imply that they're necessarily prefixed with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do agree "metrics" are essentially just tags. I also think *_numeric_tags is better suited but I also understand consistency across tracers is key. Thanks @dgoffredo to chiming in and sharing your knowledge 🙂

Simple PR which introduces the following changes:
numeric_tagsthrough the API, although the new API functions refer tometricsfor consistency with other tracers (e.g. PHP).dd-trace-cppis used by other internal projects such as ASM.