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

[pkg/otlp] Backport changes from Datadog exporter #12452

Merged
merged 6 commits into from
Jun 22, 2022

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Jun 20, 2022

What does this PR do?

Backports changes on the pkg/otlp/model done in open-telemetry/opentelemetry-collector-contrib#11030 and adapts code to work with it.

In particular, the concept of Source is introduced. A source uniquely identifies where a piece of telemetry data comes from. It can either be a host or a serverless task/function (currently only ECS Fargate).

Motivation

Keep codebases in sync. Allow open-telemetry/opentelemetry-collector-contrib#9693 to be merged.

Additional Notes

This does not have any user-facing changes. The code is split into two commits for easier review:

  1. 175c787 does the backport and only modifies code in pkg/otlp/model.
  2. 99f0170 modifes code outside of pkg/otlp/model

Reviewer's Checklist

  • If known, an appropriate milestone has been selected; otherwise the Triage milestone is set.
  • Use the major_change label if your change either has a major impact on the code base, is impacting multiple teams or is changing important well-established internals of the Agent. This label will be use during QA to make sure each team pay extra attention to the changed behavior. For any customer facing change use a releasenote.
  • A release note has been added or the changelog/no-changelog label has been applied.
  • Changed code has automated tests for its functionality.
  • Adequate QA/testing plan information is provided if the qa/skip-qa label is not applied.
  • At least one team/.. label has been applied, indicating the team(s) that should QA this change.
  • If applicable, docs team has been notified or an issue has been opened on the documentation repo.
  • If applicable, the need-change/operator and need-change/helm labels have been applied.
  • If applicable, the config template has been updated.

@mx-psi mx-psi added this to the 7.38.0 milestone Jun 20, 2022
@mx-psi mx-psi marked this pull request as ready for review June 20, 2022 10:50
@mx-psi mx-psi requested review from a team as code owners June 20, 2022 10:50
@mx-psi mx-psi requested a review from gbbr June 20, 2022 10:50
pkg/otlp/model/attributes/source.go Outdated Show resolved Hide resolved
pkg/otlp/model/attributes/source.go Show resolved Hide resolved
Comment on lines +26 to +27
// InvalidKind is an invalid kind. It is the zero value of Kind.
InvalidKind Kind = ""
Copy link
Contributor

@gbbr gbbr Jun 21, 2022

Choose a reason for hiding this comment

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

I'd use the Go-style (see https://pkg.go.dev/net/http constants for Status* as one example) way of declaring constants representative of a type, and that is prefixing them with the type name (or some form of it), e.g.:

  • KindInvalid
  • KindHostname
  • KindAWSECSFargate

Copy link
Member Author

Choose a reason for hiding this comment

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

Since this PR is a backport and this would affect the public API, I will do this separately; I created AP-1722 to track this

AWSECSFargateKind Kind = "task_arn"
)

// Source represents a telemetry source.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this what we'd call a resource in OpenTelemetry? If so, wouldn't that be better? I'm still a newbie here ⚠️ !

Copy link
Member Author

Choose a reason for hiding this comment

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

Kinda, it's the Datadog-version of a resource. The goal is to have a single datatype that can represent hosts and serverless functions. Previously we had the RunningTagFromAttributes and HostnameFromAttributes, but since something can't be considered both a host and serverless, this simplifies the implementation a bit.

Comment on lines +47 to +48
// Provider identifies a source.
type Provider interface {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nice opportunity to call it Sourcer, which is very standard for interfaces having only one function (calling them the name of that function + the *er suffix). From a contextual perspective source.Provider is nicer than source.Sourcer, but the latter ain't that bad either.

type noSourceProvider struct{}

func (*noSourceProvider) Source(context.Context) (source.Source, error) {
return source.Source{Kind: source.HostnameKind, Identifier: ""}, nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a source.KindUnknown type specifically for this?

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 think the right approach is to enforce passing the sourcer as a required argument in translator.New, to avoid this whole thing. I will do this together with the other changes on a future PR, since it affects public API

pkg/trace/api/otlp.go Outdated Show resolved Hide resolved
pkg/trace/api/otlp.go Outdated Show resolved Hide resolved
pkg/trace/api/otlp.go Show resolved Hide resolved
pkg/trace/api/otlp.go Show resolved Hide resolved
@mx-psi mx-psi requested a review from gbbr June 21, 2022 10:01
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

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

Thanks for clarifying. LGTM!

@mx-psi mx-psi merged commit 8a3912b into main Jun 22, 2022
@mx-psi mx-psi deleted the mx-psi/backport-ecs-fargate-changes branch June 22, 2022 10:25
usamasaqib pushed a commit that referenced this pull request Jul 4, 2022
* [pkg/otlp/model] Backport changes from Datadog exporter

* Adapt serializer and trace OTLP code to new changes

* Address comments on Kubernetes code

* [pkg/otlp/model] Rename to unknown source

* [pkg/trace] Address comments

* update ReceiveResourceSpans comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants