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

Add internal data -> OC compatibility shims to processors and exporters #667

Merged
merged 1 commit into from
Mar 26, 2020

Conversation

dmitryax
Copy link
Member

@dmitryax dmitryax commented Mar 19, 2020

Description:
In order to start migrating components from OC to internal data, all parts of the pipeline should be able to automatically convert back to OC if downstream component doesn't work with internal data structure yet

Testing: Unit tests

TODO: Support of mutating data processors will be added in a subsequent PR

// CreateMetricsCloningFanOutConnector is a placeholder function for now.
// It supposed to create an old type connector or a new type connector based on type of provided metrics consumer.
func CreateMetricsCloningFanOutConnector(baseMetricsConsumers []consumer.BaseMetricsConsumer) consumer.MetricsConsumer {
// TODO: CreateMetricsCloningFanOutConnector doesn't support new type of consumers
Copy link
Member

Choose a reason for hiding this comment

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

Can we make this fails loudly if we attempt to use this function until this TODO is done? Otherwise this may become a hard to catch latent race bug if we forget to implement it. panic is fine if we cannot return an error. I know we don't yet have any components that implement the new V2 interfaces, so the panic will not be actually hit. It will just be a safeguard that we will discover the problem quickly if we forget about it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point. Added panic

metricsConsumersV2 := make([]consumer.MetricsConsumerV2, 0, len(mcs))
anyMetricsConsumersV2 := false
for _, mc := range mcs {
metricsConsumer := mc.(consumer.MetricsConsumer)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this be?

Suggested change
metricsConsumer := mc.(consumer.MetricsConsumer)
metricsConsumer, ok := mc.(consumer.MetricsConsumer)
if ok ...

Otherwise if mc is consumer.MetricsConsumerV2 this will panic.

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct. Caught it when adding tests as well. Moved it under the right condition.

traceConsumersV2 := make([]consumer.TraceConsumerV2, 0, len(tcs))
anyTraceConsumersV2 := false
for _, tc := range tcs {
traceConsumer := tc.(consumer.TraceConsumer)
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

}

// Old type processor and a new type consumer usecase is not supported.
return nil, errors.New("OC Traces -> internal data format translation is not supported")
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a TODO to also support this case? We now have Oc->internal translation so this should not be difficult to implement. This will allow us to mix old and new style components in the pipeline.
We can implement it in a separate PR.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, makes sense. Updated

@dmitryax dmitryax force-pushed the feature/dmitryax/shims branch from a5274d1 to c3d571e Compare March 20, 2020 01:01
@codecov-io
Copy link

codecov-io commented Mar 20, 2020

Codecov Report

Merging #667 into master will decrease coverage by 0.16%.
The diff coverage is 59.67%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #667      +/-   ##
==========================================
- Coverage   75.98%   75.82%   -0.17%     
==========================================
  Files         164      164              
  Lines       11614    11710      +96     
==========================================
+ Hits         8825     8879      +54     
- Misses       2365     2403      +38     
- Partials      424      428       +4     
Impacted Files Coverage Δ
processor/cloningfanoutconnector.go 61.90% <0.00%> (-21.08%) ⬇️
service/builder/exporters_builder.go 64.07% <42.85%> (-4.06%) ⬇️
service/builder/pipelines_builder.go 75.65% <47.05%> (-11.45%) ⬇️
service/builder/receivers_builder.go 76.22% <75.00%> (ø)
processor/fanoutconnector.go 90.32% <86.95%> (-9.68%) ⬇️
config/config.go 99.24% <100.00%> (ø)
exporter/factory.go 100.00% <100.00%> (ø)
processor/factory.go 100.00% <100.00%> (ø)
translator/internaldata/resource_to_oc.go 70.14% <0.00%> (+5.97%) ⬆️

Continue to review full report at Codecov.

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

@dmitryax dmitryax force-pushed the feature/dmitryax/shims branch from c3d571e to 0dc5567 Compare March 20, 2020 01:17
@dmitryax dmitryax force-pushed the feature/dmitryax/shims branch from 0dc5567 to 4e40990 Compare March 24, 2020 16:47
@tigrannajaryan
Copy link
Member

@dmitryax the build failed.

@dmitryax dmitryax force-pushed the feature/dmitryax/shims branch 2 times, most recently from a5b173c to abe42d4 Compare March 24, 2020 19:28
In order to start migrating components from OC to internal data, all parts of the pipeline should be able to automatically convert back to OC if downstream component doesn't work with internal data structure
@dmitryax dmitryax force-pushed the feature/dmitryax/shims branch from abe42d4 to 67a6c08 Compare March 26, 2020 04:16
Copy link
Contributor

@pjanotti pjanotti left a comment

Choose a reason for hiding this comment

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

LGTM. Nit: the type assertions with else clauses or with returning in the ok case perhaps a better represented with type switches, and it makes the "default" case more explicit.

@pjanotti pjanotti merged commit 7a85f6f into open-telemetry:master Mar 26, 2020
MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
…lemetry#667)

* Switch MinMaxSumCount to a mutex lock instead of StateLocker

With multiple values being modified for each Update(), a single mutex
lock and non-atomic operations ends up being faster than making each
value update into an atomic operation.

* Remove StateLocker implementation and comparison benchmarks

* Remove field offset tests. No longer required with no atomics.

Co-authored-by: Joshua MacDonald <[email protected]>
MovieStoreGuy pushed a commit to atlassian-forks/opentelemetry-collector that referenced this pull request Nov 11, 2021
Fixes open-telemetry#657

With the changes in open-telemetry#667 and open-telemetry#669 to use a plain-old-mutex for
concurrent access of Histogram and MinMaxSumCount aggregators,
the StateLocker implementation is no longer used in the project.

Co-authored-by: Joshua MacDonald <[email protected]>
hughesjj pushed a commit to hughesjj/opentelemetry-collector that referenced this pull request Apr 27, 2023
Troels51 pushed a commit to Troels51/opentelemetry-collector that referenced this pull request Jul 5, 2024
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.

4 participants