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

[Labelers Not adding attributes]: [Using the Labeler from the context attributes are not added to spans, only metrics] #1401

Open
vlurgio opened this issue Feb 13, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@vlurgio
Copy link

vlurgio commented Feb 13, 2025

What version of ogen are you using?

ogen version v1.8.1 (built with go1.23.2) darwin/arm64

Can this issue be reproduced with the latest version?

Yes

What did you do?

Using the labeler from the context in handler functions does not add the custom attributes to the span.

Using a labeler like this

	labeler, ok := api.LabelerFromContext(ctx)
    if ok {
	    labeler.Add(
		    attribute.KeyValue{Key: "attr1", Value: attribute.StringValue(p.attr1)},
		    attribute.KeyValue{Key: "attr2", Value: attribute.StringValue(p.att2)},
	    )
    }

In the implemented interfaces fails as the following code in the generated handler layer has a bug in it.

		if code != 0 {
			codeAttr := semconv.HTTPResponseStatusCode(code)
			attrs = append(attrs, codeAttr)
			span.SetAttributes(codeAttr)
		}
		attrOpt := metric.WithAttributes(codeAttr)

should be

		if code != 0 {
			codeAttr := semconv.HTTPResponseStatusCode(code)
			attrs = append(attrs, codeAttr)
			span.SetAttributes(attrs...)
		}
		attrOpt := metric.WithAttributes(codeAttr)

right now it's using the unappended to list to set the attributes on the span. Would love to open a PR to fix this.

What did you expect to see?

Custom Attributes added to a span.

What did you see instead?

Attributes are not added to spans.

@vlurgio vlurgio added the bug Something isn't working label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant