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

POC for trsnaltor for attributes #222

Closed
wants to merge 1 commit into from
Closed

Conversation

mx-psi
Copy link
Member

@mx-psi mx-psi commented Dec 14, 2023

What does this PR do?

Motivation

Copy link
Member

@mackjmr mackjmr left a comment

Choose a reason for hiding this comment

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

This approach looks good to me 👍 Only important part missing is to avoid counting the metric itself, other than that just a few nits.

}

// MapToSource gets a telemetry signal source from its attributes.
func (p *Translator) MapToSource(ctx context.Context, attrs pcommon.Map, set attribute.Set) (source.Source, bool) {
Copy link
Member

Choose a reason for hiding this comment

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

Seems like the PR is missing the logic to avoid counting datadog.otlp_translator.attributes.missing_source ?

func extractHostNameAndServiceName(resourceAttrs pcommon.Map, logAttrs pcommon.Map) (host string, service string) {
if src, ok := attributes.SourceFromAttrs(resourceAttrs); ok && src.Kind == source.HostnameKind {
func (t *Translator) extractHostNameAndServiceName(resourceAttrs pcommon.Map, logAttrs pcommon.Map) (host string, service string) {
// TODO: This maps the same resource multiple times and generates the metric multiple times :(
Copy link
Member

Choose a reason for hiding this comment

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

This should be fixable by refactoring logs code and taking plog.ResourceLogsSlice here and here as an argument, but yeah don't think this is in the scope of the work here

"github.com/DataDog/opentelemetry-mapping-go/pkg/otlp/attributes/source"
)

const missingSourceMetricName string = "datadog.otlp_translator.attributes.missing_source"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
const missingSourceMetricName string = "datadog.otlp_translator.attributes.missing_source"
const missingSourceMetricName string = "datadog.otlp_translator.resources.missing_source"

Technically we are counting the number of resources without host identifying attributes, rather than attributes ?

Copy link
Member

Choose a reason for hiding this comment

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

(Assuming the logs code gets refactored)

missingSources, err := meter.Int64Counter(
missingSourceMetricName,
metric.WithDescription("OTLP payloads that are missing a source (e.g. hostname)"),
metric.WithUnit("[payload]"),
Copy link
Member

Choose a reason for hiding this comment

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

may need to change this to {resource} if you agree with the suggestion above. In both cases I believe it needs to be curly braces.

@mx-psi
Copy link
Member Author

mx-psi commented Dec 20, 2023

Last part in #231, where I addressed all the comments here :)

@mx-psi mx-psi closed this Dec 20, 2023
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.

2 participants