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

update semantic conventions to v1.19 #965

Merged
merged 8 commits into from
Apr 26, 2023
Merged

update semantic conventions to v1.19 #965

merged 8 commits into from
Apr 26, 2023

Conversation

brettmc
Copy link
Collaborator

@brettmc brettmc commented Apr 12, 2023

taking a lead from the go SIG, who seem to be using semconv the most, I've split
semantic conventions up into smaller files representing top-level semconvs.
I can't find any usage of the various AttributeValues being used, and other SIGs
no longer generate them, so removing them
[BREAKING] some attributes have moved, notably EXCEPTION_ESCAPED from TraceAttributes to EventAttributes, which requires a corresponding fix in some contrib packages.

@brettmc brettmc requested a review from a team April 12, 2023 01:22
@codecov
Copy link

codecov bot commented Apr 12, 2023

Codecov Report

Merging #965 (4d38ec4) into main (a06e5e4) will decrease coverage by 0.63%.
The diff coverage is 68.57%.

❗ Current head 4d38ec4 differs from pull request most recent head c217edb. Consider uploading reports for the commit c217edb to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##               main     #965      +/-   ##
============================================
- Coverage     82.95%   82.33%   -0.63%     
- Complexity     2165     2179      +14     
============================================
  Files           281      283       +2     
  Lines          6195     6220      +25     
============================================
- Hits           5139     5121      -18     
- Misses         1056     1099      +43     
Flag Coverage Δ
7.4 80.99% <68.57%> (-0.62%) ⬇️
8.0 82.27% <68.57%> (-0.64%) ⬇️
8.1 82.46% <71.64%> (-0.57%) ⬇️
8.2 82.46% <71.64%> (-0.57%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...I/Common/Instrumentation/CachedInstrumentation.php 83.33% <0.00%> (ø)
src/API/Logs/NoopLogger.php 100.00% <ø> (ø)
src/Contrib/Otlp/ProtobufSerializer.php 0.00% <0.00%> (ø)
src/SDK/Metrics/Data/Exemplar.php 0.00% <0.00%> (ø)
...SDK/Metrics/Stream/AsynchronousMetricCollector.php 0.00% <0.00%> (ø)
.../SDK/Metrics/Stream/SynchronousMetricCollector.php 0.00% <0.00%> (ø)
src/SDK/Logs/ReadableLogRecord.php 91.89% <80.00%> (-2.71%) ⬇️
src/SDK/Metrics/Stream/MetricAggregator.php 96.29% <80.00%> (-3.71%) ⬇️
src/Contrib/Otlp/SpanConverter.php 98.98% <85.71%> (+0.02%) ⬆️
src/API/Behavior/LogsMessagesTrait.php 90.32% <100.00%> (-0.31%) ⬇️
... and 23 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a06e5e4...c217edb. Read the comment docs.

brettmc added 2 commits April 12, 2023 16:45
taking a lead from the go SIG, who seem to be using semconv the most, I've split
semantic conventions up into smaller files representing top-level semconvs.
I can't find any usage of the various AttributeValues being used, and other SIGs
no longer generate them, so removing them
@brettmc
Copy link
Collaborator Author

brettmc commented Apr 12, 2023

asked a question on spec channel about how to organize semconv - it looks like other SIGs are starting to create "resource" + "everything else" which is different to what we're doing.

@@ -35,7 +35,7 @@ function trace(SpanInterface $span, Closure $closure, iterable $args = [])
return $c(...$a, ...($a = []));
} catch (Throwable $e) {
$s->setStatus(StatusCode::STATUS_ERROR, $e->getMessage());
$s->recordException($e, [TraceAttributes::EXCEPTION_ESCAPED => true]);
$s->recordException($e, [EventAttributes::EXCEPTION_ESCAPED => true]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$s->recordException($e, [EventAttributes::EXCEPTION_ESCAPED => true]);
$s->recordException($e, ['exception.escaped' => true]);

Can we drop the open-telemetry/sem-conv from the API-package to avoid breaking the API on sem-conv updates?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a good question. If we did drop it, what is the point of having the sem-conv package? I've noticed that other SIGs version their semantic convention package the same as the spec version (eg 1.19.0 in this case), and presumably then pin APIs etc to that version. I have a feeling that might be very painful if packages are dependant on different versions, though.

The other thing some SIGs are doing is moving all attributes into two classes: ResourceAttributes, and SemanticAttributes, the latter being "everything except resources". That should at least solve the problem of things moving about as the spec evolves.

Copy link
Contributor

Choose a reason for hiding this comment

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

IMO contrib/instrumentation packages are the main consumers of the sem-conv package.
(Java added removed attributes to the template to avoid a BC-break open-telemetry/opentelemetry-java@188210b, I like this approach because it makes pinning to a specific version in instrumentation packages obsolete when specifying the schema url as literal instead of relying on TraceAttributes::SCHEMA_URL.)

Regarding the API dependency: even if we resolve the BC-break I don't see a reason to keep the sem-conv dependency in the API package, we only use it for a small helper function. Iff ::recordException() / exception.escaped are changed in v1 in a breaking way, we should deprecate the trace() function. (The SDK uses literals for the other 'exception.' attributes in ::recordException() too / any breaking change would very likely also affect the SDK.)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing that out - adding removed items to the template and marking them as @deprecated is a good idea. I've loosely copied java's deprecation pattern, and decided to remove the new semver classes I've added, since java hasn't done anything yet and I'd be more comfortable if they go first and we copy.

brettmc added 4 commits April 18, 2023 13:19
java has not progressed with these yet, so I think we should wait until we see what they do :)
allow deprecations of moved/removed attributes so that we don't break things across different
semconv versions (similar to how java does it, except I moved them into a file which is
imported
@brettmc brettmc merged commit 9bccde9 into open-telemetry:main Apr 26, 2023
Nevay added a commit to Nevay/opentelemetry-php that referenced this pull request Dec 7, 2023
brettmc pushed a commit that referenced this pull request Dec 7, 2023
* Fix typo "interal" -> "internal"
* Remove semconv from API deptrac ruleset
Removed in #965.
otel-php-bot pushed a commit to opentelemetry-php/api that referenced this pull request Dec 7, 2023
* Fix typo "interal" -> "internal"
* Remove semconv from API deptrac ruleset
Removed in open-telemetry/opentelemetry-php#965.
otel-php-bot pushed a commit to opentelemetry-php/sdk that referenced this pull request Dec 7, 2023
* Fix typo "interal" -> "internal"
* Remove semconv from API deptrac ruleset
Removed in open-telemetry/opentelemetry-php#965.
@kayw-geek
Copy link

Hi @brettmc, I noticed have many const be deprecated, like the TraceAttributes::HTTP_HOST, What should I use to replace these deprecated constants?

@brettmc
Copy link
Collaborator Author

brettmc commented Jan 5, 2024

The ones that we deprecate (from https://github.com/open-telemetry/opentelemetry-php/blob/main/script/semantic-conventions/templates/trace_deprecations.php.partial) are attributes that were removed from upstream, and we add them back with the deprecation notice to try to avoid breaking changes for users. Because they were totally removed from semconv (rather than being deprecated there), we don't have further info about which attributes to use instead.

In the case of http.host, it was removed from open-telemetry/opentelemetry-specification#2114 and from scanning the comments I think net.host.name. I'd suggest referring to https://opentelemetry.io/docs/specs/semconv/http/http-spans/ and finding the attributes that best suit the values you want to use.

@kayw-geek
Copy link

kayw-geek commented Jan 5, 2024

@brettmc I got it, Thank you for your detailed reply. The http.host should be replace by the server.address.

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