google-cloud-cpp icon indicating copy to clipboard operation
google-cloud-cpp copied to clipboard

Use OTel's semantic convention constants when we bump minimum OTel version

Open alevenberg opened this issue 1 year ago • 3 comments

In the async batch publish, we create a root span using the string instead of the constant, since it does not exist in the oldest deps.

https://github.com/googleapis/google-cloud-cpp/pull/13285/files#diff-3e8aefbb8885925f3b6c48b310f1fe9e031aa24315c084fa04cfc13ea5bd86f6R63-R66

Current:

opentelemetry::context::Context root_context;
  // TODO(https://github.com/googleapis/google-cloud-cpp/issues/13287): Use the constant instead of the string.
  root_context.SetValue(/*opentelemetry::trace::kIsRootSpanKey=*/"is_root_span", true);
  options.parent = root_context;

Suggestion:

  root_context =
      root_context.SetValue(opentelemetry::trace::kIsRootSpanKey, true);
  options.parent = root_context;

  • [ ] /*sc::kNetworkTransport=*/"network.transport"
  • [ ] /*sc::kHttpRequestMethod=*/"http.request.method"
  • [ ] /*sc::kUrlFull=*/"url.full"
  • [ ] /*sc::kServerAddress=*/"server.address"
  • [ ] /*sc::kServerPort=*/"server.port"
  • [ ] /*sc::kClientAddress=*/"client.address"
  • [ ] /*sc::kClientPort=*/"client.port"

alevenberg avatar Dec 13 '23 16:12 alevenberg

There are a few more of these semantic convention names we would like to update when possible. Can we have this issue encompass all of them? A checklist would be cool.

dbolduc avatar Dec 13 '23 19:12 dbolduc

We could add comments with issue in the code instead?

alevenberg avatar Dec 13 '23 19:12 alevenberg

We could add comments with issue in the code instead?

The code is already ugly, let's not make it fugly. It will be sufficient to have a list of strings to find and replace. I started a checklist for the semantic conventions I reverted in #12992.

dbolduc avatar Dec 13 '23 19:12 dbolduc