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

feat/logattributes support map type #3821

Merged

Conversation

Abinet18
Copy link
Contributor

@Abinet18 Abinet18 commented May 18, 2023

Which problem is this PR solving?

Adds support for map in attributes for logs (for events to create nested attributes as in event.data)

Short description of the changes

Make type changes in logs api and respective changes in the logs sdk, otlp-transformer

Type of change

  • 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?

  • Unit tests in logs-sdk
  • Tested with a page view event that emits logs with event.data as a map of attributes

Checklist:

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

@Abinet18 Abinet18 requested a review from a team May 18, 2023 17:52
@codecov
Copy link

codecov bot commented May 18, 2023

Codecov Report

Merging #3821 (08cc53c) into main (a4f0b42) will increase coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 08cc53c differs from pull request most recent head 3adadce. Consider uploading reports for the commit 3adadce to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3821      +/-   ##
==========================================
+ Coverage   92.94%   92.96%   +0.01%     
==========================================
  Files         299      299              
  Lines        9075     9082       +7     
  Branches     1851     1855       +4     
==========================================
+ Hits         8435     8443       +8     
+ Misses        640      639       -1     
Impacted Files Coverage Δ
...erimental/packages/api-logs/src/types/LogRecord.ts 100.00% <ø> (ø)
...l/packages/otlp-transformer/src/common/internal.ts 100.00% <ø> (ø)
...mental/packages/otlp-transformer/src/logs/index.ts 100.00% <100.00%> (ø)
experimental/packages/sdk-logs/src/LogRecord.ts 97.93% <100.00%> (+0.11%) ⬆️

... and 1 file with indirect coverage changes

@Abinet18 Abinet18 force-pushed the feat/logattributes-support-map-type branch from ffd5d8a to bac7e23 Compare May 18, 2023 19:14
@Abinet18 Abinet18 force-pushed the feat/logattributes-support-map-type branch from bac7e23 to 9df8522 Compare May 18, 2023 19:27
@dyladan
Copy link
Member

dyladan commented May 18, 2023

Can you please provide a link to the relevant spec to make sure reviewers have it handy?

/cc @martinkuba

@Abinet18
Copy link
Contributor Author

Copy link
Member

@pichlermarc pichlermarc left a comment

Choose a reason for hiding this comment

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

Is this PR intended as a prototype for an upcoming spec, if yes, would you mind providing a link to the related PR? 🙂

I looked through the spec, and I could not find any special handling for LogAttributes that differs from the common attribute definition, which states that:

An Attribute is a key-value pair, which MUST have the following properties:

  • The attribute key MUST be a non-null and non-empty string.
  • The attribute value is either:
  • A primitive type: string, boolean, double precision floating point (IEEE 754-1985) or signed 64 bit integer.
  • An array of primitive type values. The array MUST be homogeneous,
    i.e., it MUST NOT contain values of different types.

I'm not at all against adding support for maps in event attributes, but I think we should reference the specification (or a PR in the meantime) first to have this documented somwhere.

@dyladan
Copy link
Member

dyladan commented May 25, 2023

Here is a link for the spec containing event.data as a map of attributes, https://github.com/scheler/opentelemetry-specification/blob/rum-events/specification/logs/events/semantic_conventions/browser.md#pageview

This is a fork of the spec. The current version of spec has no mention of map type attributes.

@dyladan
Copy link
Member

dyladan commented May 25, 2023

@martinkuba is the @scheler fork considered to be the prototype used by the RUM or logs SIG?

@scheler
Copy link
Contributor

scheler commented May 25, 2023

@dyladan @pichlermarc This is the correct link to the spec:
https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/logs/data-model.md#field-attributes

The log data model always supported complex attributes.

We want to leverage this support to put Event payload/data into an attribute called event.data, and this PR is to support that.

@pichlermarc
Copy link
Member

@dyladan @pichlermarc This is the correct link to the spec: open-telemetry/opentelemetry-specification@main/specification/logs/data-model.md#field-attributes

The log data model always supported complex attributes.

Ah, that makes sense, thanks for the link. 🙂 Now looking at it again, I see that attributes on the API LogRecord spec actually links to the data model, my bad.

We want to leverage this support to put Event payload/data into an attribute called event.data, and this PR is to support that.

👍

@Abinet18 Abinet18 requested a review from pichlermarc May 31, 2023 03:17
Copy link
Member

@dyladan dyladan left a comment

Choose a reason for hiding this comment

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

LGTM. I'd like to get @martinkuba 👀 on this as well if we can

@dyladan
Copy link
Member

dyladan commented Jun 1, 2023

@martinkuba wrt the discussion yesterday it looks like he made the change you suggested on the call for arbitrarily nested maps

@pichlermarc pichlermarc merged commit 8eb9bf3 into open-telemetry:main Jun 2, 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.

5 participants