Skip to content

Use otel4s semantic conventions to verify metrics definition#272

Open
iRevive wants to merge 1 commit intocommercetools:mainfrom
iRevive:topic/otel4s-improvements
Open

Use otel4s semantic conventions to verify metrics definition#272
iRevive wants to merge 1 commit intocommercetools:mainfrom
iRevive:topic/otel4s-improvements

Conversation

@iRevive
Copy link
Copy Markdown

@iRevive iRevive commented Nov 17, 2025

Hey folks, thanks for using otel4s!
The PR shows additional capabilities of otel4s and is not meant to be merged. You could adopt some ideas that could be helpful for your project.


MessagingExperimentalMetrics are generated from the specification, which includes the instrument name, description, unit, required attributes, and other details.
You can also use a generated spec to verify that exported metrics have all required attributes.

assertEquals(md.unit, Some(spec.unit), clue)

val required = spec.attributeSpecs
.filter(_.requirement.level == Requirement.Level.Required)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

You can also filter attributes by stability:

.filter(_.stability == Stability.stable)

operationDuration.recordDuration(TimeUnit.SECONDS, buildAttributes(Attributes(InternalMessagingAttributes.Send), _))
operationDuration.recordDuration(
TimeUnit.SECONDS,
buildAttributes(Attributes(InternalMessagingAttributes.Send, InternalMessagingAttributes.SendOp), _))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

@iRevive iRevive changed the title Use otel4s semantic conventions to verify metrics Use otel4s semantic conventions to verify metrics definition Nov 17, 2025
@satabin
Copy link
Copy Markdown
Collaborator

satabin commented Nov 18, 2025

Thanks a lot, I am still discovering the power of the semconv module you added :-) I will look into this and improve our integration!

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