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

chore(examples/web): use exported strings for attributes #2129

Merged
merged 4 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/web/examples/document-load/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { CompositePropagator, W3CTraceContextPropagator } from '@opentelemetry/core';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';

const provider = new WebTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'web-service-dl',
[SEMRESATTRS_SERVICE_NAME]: 'web-service-dl',
}),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/web/examples/meta/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { getWebAutoInstrumentations } from '@opentelemetry/auto-instrumentations-web';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';

const providerWithZone = new WebTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'web-service-meta',
[SEMRESATTRS_SERVICE_NAME]: 'web-service-meta',
}),
});

Expand Down
4 changes: 2 additions & 2 deletions examples/web/examples/user-interaction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ import { B3Propagator } from '@opentelemetry/propagator-b3';
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request';
import { registerInstrumentations } from '@opentelemetry/instrumentation';
import { Resource } from '@opentelemetry/resources';
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions';
import { SEMRESATTRS_SERVICE_NAME } from '@opentelemetry/semantic-conventions';

const providerWithZone = new WebTracerProvider({
resource: new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: 'web-service-ui',
[SEMRESATTRS_SERVICE_NAME]: 'web-service-ui',
}),
});

Expand Down
2 changes: 1 addition & 1 deletion examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
"@opentelemetry/instrumentation-xml-http-request": "^0.39.1",
"@opentelemetry/propagator-b3": "^1.13.0",
"@opentelemetry/sdk-trace-web": "^1.13.0",
"@opentelemetry/semantic-conventions": "^1.13.0"
"@opentelemetry/semantic-conventions": "^1.23.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

This only requires v1.22.0, but I think we can have (perhaps even want) the examples all to be updated to be using the very latest versions of deps? Not sure how strict we need to be here. If we need to back this up to ^1.22.0 later, we can do another change.

Copy link
Member

Choose a reason for hiding this comment

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

This definitely brings the example in bad state. "@opentelemetry/instrumentation-xml-http-request": "^0.39.1" depends on "@opentelemetry/semantic-conventions": "1.13.0".
So user ends up with a duplicate.

In general I think examples should be only touched if it is verified manually that result is fine as there are no automated tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does having two versions of @opentelemetry/semantic-conventions necessarily mean a bad state for the example?

The current state already has three different versions of @opentelemetry/resource, FWIW:

[23:37:57 trentm@peach:~/src/opentelemetry-js-contrib/examples/web (git:main)]
% npm ls @opentelemetry/resources
web-examples@0.26.0 /Users/trentm/src/opentelemetry-js-contrib/examples/web
├─┬ @opentelemetry/auto-instrumentations-web@0.32.3
│ ├─┬ @opentelemetry/instrumentation-fetch@0.40.0
│ │ └─┬ @opentelemetry/sdk-trace-web@1.14.0
│ │   └─┬ @opentelemetry/sdk-trace-base@1.14.0
│ │     └── @opentelemetry/resources@1.14.0
│ └─┬ @opentelemetry/instrumentation-xml-http-request@0.40.0
│   └─┬ @opentelemetry/sdk-trace-web@1.14.0
│     └─┬ @opentelemetry/sdk-trace-base@1.14.0
│       └── @opentelemetry/resources@1.14.0
├─┬ @opentelemetry/exporter-trace-otlp-http@0.39.1
│ ├─┬ @opentelemetry/otlp-transformer@0.39.1
│ │ ├── @opentelemetry/resources@1.13.0 deduped
│ │ ├─┬ @opentelemetry/sdk-logs@0.39.1
│ │ │ └── @opentelemetry/resources@1.13.0 deduped
│ │ └─┬ @opentelemetry/sdk-metrics@1.13.0
│ │   └── @opentelemetry/resources@1.13.0 deduped
│ ├── @opentelemetry/resources@1.13.0
│ └─┬ @opentelemetry/sdk-trace-base@1.13.0
│   └── @opentelemetry/resources@1.13.0 deduped
└─┬ @opentelemetry/sdk-trace-web@1.23.0
  └─┬ @opentelemetry/sdk-trace-base@1.23.0
    └── @opentelemetry/resources@1.23.0

and 7 installs of 3 different versions of @opentelemetry/semantic-conventions:

% npm ls @opentelemetry/semantic-conventions | rg -v deduped | rg semantic
│ │ └── @opentelemetry/semantic-conventions@1.14.0
│   └── @opentelemetry/semantic-conventions@1.14.0
│ │ └── @opentelemetry/semantic-conventions@1.13.0
│ │ └── @opentelemetry/semantic-conventions@1.13.0
│   └── @opentelemetry/semantic-conventions@1.13.0
│ └── @opentelemetry/semantic-conventions@1.13.0
└── @opentelemetry/semantic-conventions@1.23.0

Anyway, it is a bit of a mess. I'm not sure these PRs updating the examples/* make it worse, but I understand your point.

Getting into attempting to maintain many of these examples is a huge pain. Some of them are ancient or obsolete (B3Propagator). The examples/web/README.md, for example, explains nothing about what to expect, whether to run the docker-compose file that is included, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

This was discussed in the SIG today (https://docs.google.com/document/d/1tCyoQK49WVcE-x8oryZOTTToFm7sIeUhxFPm9g-qL1k/edit#heading=h.dvqq8u408ifx) and it was felt that we should go ahead with these semconv updates in the examples/* dirs. Trying to summarize the discussion from memory:

  • Possible multiple separate @opentelemetry/semantic-conventions versions won't break the example apps because the semconv package has no deps.
  • To the degree that users look at the examples for how to do things, it is helpful to update the semantic-conventions package usage to the new exports from v1.22.0.
  • There was some expression of hope for automated verification that examples are basically working (perhaps no more than a check that they install/compile fine). Verifying beyond that might be difficult because the examples aren't generally written to be testable. Also contributor bandwidth is an issue.

},
"homepage": "https://github.com/open-telemetry/opentelemetry-js-contrib#readme"
}