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

Remove @_spi(Metrics) annotation from metrics API #110

Merged

Conversation

simonjbeaumont
Copy link
Contributor

@simonjbeaumont simonjbeaumont commented Mar 28, 2024

Motivation

During development of the OLTP backend for Swift Metrics (see #84), the API had been annotated with @_spi(Metrics) until the API was finalised and to keep the main branch release-able. The shape of the API has now been finalised with input from other maintainers and it's time to bikeshed any naming and remove the SPI annotation, which is the purpose of this PR.

Modifications

  • Remove _@spi(Metrics) annotation from all public metrics API surface.
  • Remove OTelExemplar; it's still experimental in the latest revision of the OTel specification.
  • Remove OTelNumberDataPoint.Flags; we weren't exposing values so it serves no purpose currently.
  • Remove NoOpMetricExporter; it's not serving any purpose as a global default and is equivalent to just not bootstrapping the Swift Metrics with a backend.
  • Replace remaining public enum datamodel types with package enum types wrapped in public structs.
  • Fix typo: OTelAggregationTemporailty -> OTelAggregationTemporality.
  • Fix typo in named parameter in Opentelemetry_Proto_Metrics_V1_ResourceMetrics.init(_:) (not API).

Result

The API surface for metrics is publicly available.

@simonjbeaumont simonjbeaumont force-pushed the sb/metrics-remove-spi-annotation branch from 3ee242a to 60268c0 Compare March 28, 2024 18:01
Comment on lines 86 to 104
public enum OTelAggregationTemporailty: Equatable, Sendable {
case delta
case cumulative
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discuss: do we need to wrap these enums in a struct for API reasons?

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, I think we should, doesn't hurt to do it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I've replaced the each of the public enum types in the datamodel with a package enum wrapped in a public struct. I also removed one of them because we weren't exposing anything useful in the API (the flags).

Copy link

codecov bot commented Mar 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.96%. Comparing base (0735233) to head (b91be3b).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #110      +/-   ##
==========================================
- Coverage   98.97%   98.96%   -0.01%     
==========================================
  Files          67       67              
  Lines        1951     1939      -12     
==========================================
- Hits         1931     1919      -12     
  Misses         20       20              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sources/OTLPCore/Metrics/OTelMetricDataModel+Proto.swift Outdated Show resolved Hide resolved
Sources/OTLPCore/Metrics/OTelMetricDataModel+Proto.swift Outdated Show resolved Hide resolved
extension Opentelemetry_Proto_Common_V1_AnyValue {
package init(_ string: String) {
value = .stringValue(string)
}
}

@_spi(Metrics)
extension Opentelemetry_Proto_Metrics_V1_Exemplar {
package init(_ exemplar: OTelExemplar) {
// TODO:
Copy link
Owner

Choose a reason for hiding this comment

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

Do we want to link to an issue here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just revisited the section of the OTel spec and, at time of writing, it appears that this is still experimental1 so I'm gonna remove it entirely for now.

Footnotes

  1. https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/metrics/sdk.md#exemplar

Comment on lines 86 to 104
public enum OTelAggregationTemporailty: Equatable, Sendable {
case delta
case cumulative
}
Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, I think we should, doesn't hurt to do it.

@simonjbeaumont simonjbeaumont force-pushed the sb/metrics-remove-spi-annotation branch from 60268c0 to b91be3b Compare April 8, 2024 15:07
Copy link
Contributor Author

@simonjbeaumont simonjbeaumont left a comment

Choose a reason for hiding this comment

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

@slashmo OK, I think I addressed everything here :)

Sources/OTLPCore/Metrics/OTelMetricDataModel+Proto.swift Outdated Show resolved Hide resolved
Sources/OTLPCore/Metrics/OTelMetricDataModel+Proto.swift Outdated Show resolved Hide resolved
extension Opentelemetry_Proto_Common_V1_AnyValue {
package init(_ string: String) {
value = .stringValue(string)
}
}

@_spi(Metrics)
extension Opentelemetry_Proto_Metrics_V1_Exemplar {
package init(_ exemplar: OTelExemplar) {
// TODO:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've just revisited the section of the OTel spec and, at time of writing, it appears that this is still experimental1 so I'm gonna remove it entirely for now.

Footnotes

  1. https://github.com/open-telemetry/opentelemetry-specification/blob/v1.31.0/specification/metrics/sdk.md#exemplar

Comment on lines 86 to 104
public enum OTelAggregationTemporailty: Equatable, Sendable {
case delta
case cumulative
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I've replaced the each of the public enum types in the datamodel with a package enum wrapped in a public struct. I also removed one of them because we weren't exposing anything useful in the API (the flags).

@simonjbeaumont simonjbeaumont marked this pull request as ready for review April 8, 2024 15:10
@simonjbeaumont simonjbeaumont changed the title metrics: Remove @_spi(Metrics) annotation from metrics API Remove @_spi(Metrics) annotation from metrics API Apr 8, 2024
@simonjbeaumont
Copy link
Contributor Author

//cc @ktoso any final last words before we make the API public?

@slashmo slashmo merged commit 0380acd into slashmo:main Apr 15, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

2 participants