Skip to content
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

OpenTelemetry tracing bridge #1410

Merged
merged 38 commits into from
Apr 26, 2023
Merged

OpenTelemetry tracing bridge #1410

merged 38 commits into from
Apr 26, 2023

Conversation

dmathieu
Copy link
Member

@dmathieu dmathieu commented Apr 6, 2023

This setups a bridge (our own SDK actually) which allows us to use the OpenTelemetry APIs alongside our agent.

@dmathieu
Copy link
Member Author

dmathieu commented Apr 6, 2023

Some areas are unfortunately impossible to test (setting tags on spans/transactions for example), because the data isn't readable within the test.

@dmathieu
Copy link
Member Author

dmathieu commented Apr 6, 2023

I may have missed some things, but it's hard to say without real world usage. So I am marking this PR as ready for review.

@dmathieu dmathieu marked this pull request as ready for review April 6, 2023 15:32
@dmathieu dmathieu requested a review from a team April 11, 2023 07:46
Copy link
Contributor

@marclop marclop left a comment

Choose a reason for hiding this comment

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

just a quick review, haven't dived into all the details

haveHTTPContext = true
haveHTTPHostTag = true
httpHost = v.Value.Emit()

Copy link
Contributor

Choose a reason for hiding this comment

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

The previous attempt at the Otel bridge used a lot more attribute settings, maybe that's useful? https://github.com/elastic/apm-agent-go/pull/1203/files#diff-4bd41254646c6c5baf269f5e8128d6f7d327bd52ee17256ccedfe075bd5de1fdR70-R167

Copy link
Member Author

Choose a reason for hiding this comment

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

It seems trickier than that. The logic between the one here (from apmot) and in that branch are quite different.
Some attributes are added, and others are removed.

I wonder if we need a spec to have a consistent behavior, as every language implementation is going to have this problem.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder too. @felixbarny would you happen to know?

Copy link
Member

Choose a reason for hiding this comment

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

We don't have to map all attributes but we have to map some. We have a cross-agent spec for that: https://github.com/elastic/apm/blob/main/specs/agents/tracing-api-otel.md#attributes-mapping

Copy link
Member Author

Choose a reason for hiding this comment

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

I have updated the attributes based on the mentioned spec, while also keeping the http and db context, which aren't specified.

@dmathieu dmathieu force-pushed the otel-tracer branch 2 times, most recently from 5c0aff6 to d9803ed Compare April 17, 2023 08:00
Copy link
Contributor

@marclop marclop left a comment

Choose a reason for hiding this comment

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

Looks mostly good, just a few questions. I haven't looked at the tests in detail yet.

case "messaging.system":
s.span.Type = "messaging"
s.span.Subtype = v.Value.Emit()
serviceTargetType = v.Value.Emit()
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the spec, looks like we're not handling the messaging.url attribute:

    type = 'messaging';
    subtype = a['messaging.system'];

    if (!netName && a['messaging.url']) {
        netName = parseNetName(a['messaging.url']);
    }
    serviceTargetType = subtype;
    serviceTargetName = a['messaging.destination'] || null;

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah. The spec is weird about that. netName is never used with messaging. And with an if/else case as they have the net case would never run if the messaging one does.
This section therefore seems like dead code. I've written a note to follow up on figuring out if the spec should be fixed, but didn't get to it yet.

Copy link
Contributor

Choose a reason for hiding this comment

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

thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

After talking with @SylvainJuge about it, I have opened a spec fix: elastic/apm#787

Copy link
Contributor

@marclop marclop left a comment

Choose a reason for hiding this comment

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

Looks good! Thanks for bearing with me with all the comments. It was a pretty big PR to review.

@dmathieu dmathieu merged commit 2c2d789 into main Apr 26, 2023
@dmathieu dmathieu deleted the otel-tracer branch April 26, 2023 08:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants