Skip to content

OTLP exporter: encode instrumentation scope schema url and attributes to otlp proto #4359

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

Merged

Conversation

dbarker
Copy link
Member

@dbarker dbarker commented Dec 16, 2024

Description

Fixes #4358

This PR updates the OTLP encoding methods to encode the Instrumentation Scope schema url and attributes to the proto messages for logs, metrics and traces.

Without this change the schema url and attributes set on the GetMeter, GetTracer, and GetLogger methods from providers are not exported in OTLP protobuf messages.

Unit tests have been updated to check these fields are populated with the fix.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

This PR adds new cases to the logs, metrics, and trace encoding tests in opentelemetry-exporter-otlp-proto-common to cover the instrumentation scope schema url and attributes.

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

…messages. update tests to cover the schema_url and attributes.
@dbarker dbarker requested a review from a team as a code owner December 16, 2024 06:25
@dbarker
Copy link
Member Author

dbarker commented Dec 18, 2024

Ready for review. Thanks in advance for the feedback!

dbarker and others added 2 commits December 23, 2024 09:40
Co-authored-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>
@xrmx
Copy link
Contributor

xrmx commented Dec 24, 2024

@dbarker fyi no need to update this at every commit, we usually merge main before merging or during reviews 😅

@dbarker
Copy link
Member Author

dbarker commented Dec 24, 2024

@dbarker fyi no need to update this at every commit, we usually merge main before merging or during reviews 😅

haha.. thanks for the heads up and review. Just making sure it is up to date and conflict free.. :)

@dbarker
Copy link
Member Author

dbarker commented Jan 13, 2025

@xrmx Any chance you can review this week? I'd like to get this in for the next release if possible. Happy to address any issues you see. Thanks.

@dbarker
Copy link
Member Author

dbarker commented Feb 12, 2025

I've resolved the conflicts. Anything else needed to run CI and merge?

@dimaqq
Copy link
Contributor

dimaqq commented Feb 18, 2025

Q: #4358 (comment)

@dimaqq
Copy link
Contributor

dimaqq commented Feb 20, 2025

Btw., I would call this a "new feature" not a bug fix.
Even though the Python API is not extended, the binary output "ABI?" is essentially extended and thus has feature-like implications on other OTEL components.

@dbarker
Copy link
Member Author

dbarker commented Feb 20, 2025

Btw., I would call this a "new feature" not a bug fix. Even though the Python API is not extended, the binary output "ABI?" is essentially extended and thus has feature-like implications on other OTEL components.

I agree this could easily be considered a feature since it covers a few items in the spec that may have come out since the otlp-proto-common module was implemented. The protobuf otlp spec version doesn't change with this though so no worries about an interface impact.

@xrmx xrmx enabled auto-merge (squash) March 3, 2025 10:16
@xrmx xrmx merged commit 8e3c7d2 into open-telemetry:main Mar 3, 2025
384 checks passed
@dimaqq
Copy link
Contributor

dimaqq commented Mar 4, 2025

Belated +1 on the inclusion of the missing InstrumentationScope.attributes!

dimaqq added a commit to dimaqq/otlp-json that referenced this pull request Mar 4, 2025
@dbarker dbarker deleted the fix_instrumentation_scope_encoding_to_otlp branch March 9, 2025 06:46
@dimaqq
Copy link
Contributor

dimaqq commented Mar 23, 2025

1.31.0 has been released including this change.
I don't see schema URLs in the output in the default, naive setup though.
Is it so that the SDK doesn't actually set the schema URLs?

@dbarker
Copy link
Member Author

dbarker commented Mar 26, 2025

1.31.0 has been released including this change. I don't see schema URLs in the output in the default, naive setup though. Is it so that the SDK doesn't actually set the schema URLs?

@dimaqq I can see scope schema urls and attributes coming through to the otel-collector debug exporter in my application (testing main at db2dd1e today). This is working for me with metrics and traces.

Here is an example of the scope attributes and schema url on ScopeSpans.

ResourceSpans #2
Resource SchemaURL: 
Resource attributes:
     -> telemetry.sdk.language: Str(python)
     -> telemetry.sdk.name: Str(opentelemetry)
     -> telemetry.sdk.version: Str(1.32.0.dev0)
     -> service.name: Str(service_client_py)
     -> host.name: Str(dev_host)
     -> host.arch: Str(amd64)
     -> process.executable.name: Str(service_client_py)
     -> ros.distro.name: Str(jazzy)
     -> ros.distro.version: Str(2)
     -> ros.version.rclpy: Str(7.1.2)
ScopeSpans #0
ScopeSpans SchemaURL: hello!
InstrumentationScope ros2_opentelemetry_service_client 
InstrumentationScope attributes:
     -> ros.node.name: Str(service_client_py)
     -> ros.node.namespace: Str(/)
     -> ros.entity.type: Str(service_client)
     -> ros.service.name: Str(/add_three_ints)

@dimaqq
Copy link
Contributor

dimaqq commented Mar 26, 2025

Right, I figured as much.

If the url is manually set, it’s exported, but the SDK doesn’t set the urls by default. That is for the “opentelemetry” parts like the resource in your example.

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.

OTLP proto encoding methods are missing instrumentation scope schema url and attributes
4 participants