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

refactor(attributes): move enums to @opentelemetry/semantic-conventions #1160

Merged
merged 9 commits into from
Jun 15, 2020

Conversation

markwolff
Copy link
Member

@markwolff markwolff commented Jun 9, 2020

Which problem is this PR solving?

Short description of the changes

  • Moves common span attributes names defined by specs to @opentelemetry/semantic-conventions package.

https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions

@markwolff
Copy link
Member Author

Actually it looks like #718 already exists. I can close this in favor of that one if we are able to resolve the conflicts there

@dyladan
Copy link
Member

dyladan commented Jun 9, 2020

Looks like #718 is stale since january

Copy link
Member

@mayurkale22 mayurkale22 left a comment

Choose a reason for hiding this comment

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

Nice 👍

@markwolff
Copy link
Member Author

markwolff commented Jun 9, 2020

re: #718 (review), was there ever alignment on this living in core vs api? I think there's a good case for it living in api, since these will primarily be useful for library / application owners using the APIs.

I agree with const enum over enum, as long as we are okay with this remaining a flat structure, since that is the only way to use const enums. We could create separate "structured" vars to solve for this though

const enum AttributeNames { ... }

const db = {
  required: {
    statement: AttributeNames.DB_STATEMENT,
  }
}

edit: looks like using const enum will break a lot of use cases. For example, to get our own tests to pass w/ ts-mocha I needed to prefix with TS_NODE_TYPE_CHECK=true

@codecov
Copy link

codecov bot commented Jun 10, 2020

Codecov Report

Merging #1160 into master will decrease coverage by 0.20%.
The diff coverage is 81.48%.

@@            Coverage Diff             @@
##           master    #1160      +/-   ##
==========================================
- Coverage   92.37%   92.17%   -0.21%     
==========================================
  Files         119      120       +1     
  Lines        3447     3410      -37     
  Branches      700      697       -3     
==========================================
- Hits         3184     3143      -41     
- Misses        263      267       +4     
Impacted Files Coverage Δ
...lemetry-semantic-conventions/src/trace/database.ts 0.00% <0.00%> (ø)
...elemetry-semantic-conventions/src/trace/general.ts 0.00% <0.00%> (ø)
...entelemetry-semantic-conventions/src/trace/http.ts 0.00% <0.00%> (ø)
...pentelemetry-semantic-conventions/src/trace/rpc.ts 0.00% <0.00%> (ø)
packages/opentelemetry-plugin-http/src/utils.ts 97.42% <93.33%> (ø)
packages/opentelemetry-plugin-grpc/src/grpc.ts 96.79% <100.00%> (ø)
packages/opentelemetry-plugin-http/src/http.ts 97.90% <100.00%> (ø)
...s/opentelemetry-plugin-xml-http-request/src/xhr.ts 79.31% <100.00%> (ø)
... and 2 more

@dyladan
Copy link
Member

dyladan commented Jun 10, 2020

Unfortunately const enum has a lot of issues. It also doesn't play well with some bundlers for some reason. I think it might make sense to have these constants live in a separate package. Also, the spec has been working on a code generator for semantic convention constants that we will eventually want to migrate over to use, so I would caution against pushing this into the API only to have it removed later.

@markwolff
Copy link
Member Author

I think it might make sense to have these constants live in a separate package. Also, the spec has been working on a code generator for semantic convention constants that we will eventually want to migrate over to use, so I would caution against pushing this into the API only to have it removed later.

I agree code generation seems like a much better option than baking it into api and I imagine the same thinking applies to core as well. If so, this issue&PR should just be closed / changed to a tracking issue for that eventual addition. WDTY?

@dyladan
Copy link
Member

dyladan commented Jun 10, 2020

For now, I would say if we're going to centralize the constants, we should do so in a new package @opentelemetry/semantic-conventions or similar which can be deprecated or updated when the code gen is available

@markwolff markwolff changed the title refactor(attributes): move enums to core refactor(attributes): move enums to @opentelemetry/semantic-conventions Jun 11, 2020
Copy link
Member

@mwear mwear 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 will point out that the component semantic convention was removed: open-telemetry/opentelemetry-specification#447. We can handle its removal separately.

@mayurkale22 mayurkale22 merged commit 0596054 into open-telemetry:master Jun 15, 2020
@markwolff markwolff deleted the core-attributes branch June 15, 2020 18:27
@markwolff markwolff mentioned this pull request Jun 18, 2020
1 task
pichlermarc pushed a commit to dynatrace-oss-contrib/opentelemetry-js that referenced this pull request Dec 15, 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.

[Refactor][Plugins] Move common attributes to Core/Base
5 participants