Skip to content

datadog: span portion of new tracing library#25121

Merged
wbpcode merged 18 commits into
envoyproxy:mainfrom
DataDog:david.goffredo/dd-trace-cpp-5/9-span
Feb 12, 2023
Merged

datadog: span portion of new tracing library#25121
wbpcode merged 18 commits into
envoyproxy:mainfrom
DataDog:david.goffredo/dd-trace-cpp-5/9-span

Conversation

@dgoffredo
Copy link
Copy Markdown
Contributor

This is part of the initiative described in #23958.

This revision introduces a new library dependency for Datadog tracing, and adds a component that will be used in the future when more of the new library is integrated into the Datadog tracing extension.

This revision also contains all of the changes from #25003, on which it depends. When that PR is merged, the diff of this PR will shrink.

Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
…Span

Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
@repokitteh-read-only repokitteh-read-only Bot added the deps Approval required for changes to Envoy's external dependencies label Jan 24, 2023
@repokitteh-read-only
Copy link
Copy Markdown

CC @envoyproxy/dependency-shepherds: Your approval is needed for changes made to (bazel/.*repos.*\.bzl)|(bazel/dependency_imports\.bzl)|(api/bazel/.*\.bzl)|(.*/requirements\.txt)|(.*\.patch).
envoyproxy/dependency-shepherds assignee is @moderation

🐱

Caused by: #25121 was opened by dgoffredo.

see: more, trace.

@dgoffredo dgoffredo changed the title datadog: Span portion of new tracing library datadog: span portion of new tracing library Jan 24, 2023
@RyanTheOptimist
Copy link
Copy Markdown
Contributor

/assign @jmarantz

@moderation
Copy link
Copy Markdown
Contributor

/lgtm deps

@repokitteh-read-only repokitteh-read-only Bot removed the deps Approval required for changes to Envoy's external dependencies label Jan 26, 2023
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
@dgoffredo
Copy link
Copy Markdown
Contributor Author

ERROR: From ./test/extensions/tracers/datadog/span_test.cc
ERROR: ./test/extensions/tracers/datadog/span_test.cc:114: Don't use mktime; use absl::Time equivalent instead
ERROR: check format failed. diff has been applied'

I guess I'll use absl::FromCivil and absl::ToChronoTime instead.

Comment thread test/extensions/tracers/datadog/span_test.cc Outdated
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Comment thread test/extensions/tracers/datadog/span_test.cc Outdated
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great; really nicely tested. Just a few nits.

I think @moderation should look at this also for span semantics.

Comment thread source/extensions/tracers/datadog/span.cc Outdated
SystemTime start_time) {
if (!span_) {
// I don't expect this to happen. This means that `spawnChild` was called
// after `finishSpan`.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use an ENVOY_BUG here (logs a message in production build, asserts in debug/default builds)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might be worth doing.

I'd reserve assert and friends for cases where the detected behavior is in violation of the component's contract. Because this Span has the escape hatch of going into "null-mode," it's not necessary. By that reasoning, perhaps the code comment is not necessary either.

You mentioned the idea of @moderation looking over the behavior of this Span. Maybe they can decide whether "spawn-after-finish" ought to be considered forbidden in these tracing implementations.

Comment thread source/extensions/tracers/datadog/span.h
Comment thread source/extensions/tracers/datadog/time_util.h Outdated
Comment thread test/extensions/tracers/datadog/span_test.cc Outdated
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
@wbpcode
Copy link
Copy Markdown
Member

wbpcode commented Feb 2, 2023

Please merge main and resolve the conflict first. Thanks.

Copy link
Copy Markdown
Member

@wbpcode wbpcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM overall. It's great. Only some minor comments.

Comment thread source/extensions/tracers/datadog/span.cc Outdated
Comment thread source/extensions/tracers/datadog/time_util.h Outdated
Comment thread source/extensions/tracers/datadog/span.cc
jmarantz
jmarantz previously approved these changes Feb 3, 2023
Copy link
Copy Markdown
Contributor

@jmarantz jmarantz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this all looks good from my perspective modulo @wbpcode comments.

I think it might need a main merge to kick off CI also.

Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
@dgoffredo
Copy link
Copy Markdown
Contributor Author

#24826 ☹️

Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
@dgoffredo
Copy link
Copy Markdown
Contributor Author

dgoffredo commented Feb 4, 2023

test/extensions/tracers/datadog/span_test.cc:292:47: error: expression with side effects will be evaluated despite being used as an operand to 'typeid' [-Werror,-Wpotentially-evaluated-expression]
  EXPECT_EQ(typeid(Tracing::NullSpan), typeid(*child));
                                              ^
1 error generated.

That's a new one.

I suppose instead of this:

  const Tracing::SpanPtr child =
      span.spawnChild(Tracing::MockConfig{}, "child", time_.timeSystem().systemTime());
  EXPECT_NE(nullptr, child);
  EXPECT_EQ(typeid(Tracing::NullSpan), typeid(*child));

it wants this:

  const Tracing::SpanPtr child =
      span.spawnChild(Tracing::MockConfig{}, "child", time_.timeSystem().systemTime());
  EXPECT_NE(nullptr, child);
  Tracing::Span& child_span = *child;
  EXPECT_EQ(typeid(Tracing::NullSpan), typeid(child_span));

I'll make that change and see if it helps.

Signed-off-by: David Goffredo <david.goffredo@datadoghq.com>
@jmarantz
Copy link
Copy Markdown
Contributor

@moderation I've lgtm'd can you look this over and merge if you are good with it?

@moderation
Copy link
Copy Markdown
Contributor

@jmarantz I don't have merge permissions but happy to see this move ahead as it will allow us to remove some old dependencies. Maybe @phlax can merge?

@wbpcode wbpcode merged commit e626ac0 into envoyproxy:main Feb 12, 2023
if (!span_) {
return std::string{};
}
return absl::StrCat(absl::Hex(span_->id()));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dgoffredo Is this right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants