forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[chore] [receiver/datadog] Refactor translation files into internal p…
…ackage (open-telemetry#34160) **Description:** This PR is a follow-up to open-telemetry#33957. It refactors the Datadog receiver files to remove internal methods and structures from the public API and into an internal directory. **Link to tracking Issue:** open-telemetry#18278 **Testing:** This is a refactor, so no new unit tests have been added.
- Loading branch information
1 parent
aab1424
commit 74af245
Showing
11 changed files
with
94 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
receiver/datadogreceiver/internal/translator/metrics_translator.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package translator // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/datadogreceiver/internal/translator" | ||
|
||
import ( | ||
"sync" | ||
|
||
"go.opentelemetry.io/collector/component" | ||
"go.opentelemetry.io/collector/pdata/pcommon" | ||
|
||
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics/identity" | ||
) | ||
|
||
type MetricsTranslator struct { | ||
sync.RWMutex | ||
buildInfo component.BuildInfo | ||
lastTs map[identity.Stream]pcommon.Timestamp | ||
stringPool *StringPool | ||
} | ||
|
||
func NewMetricsTranslator(buildInfo component.BuildInfo) *MetricsTranslator { | ||
return &MetricsTranslator{ | ||
buildInfo: buildInfo, | ||
lastTs: make(map[identity.Stream]pcommon.Timestamp), | ||
stringPool: newStringPool(), | ||
} | ||
} | ||
|
||
func (mt *MetricsTranslator) streamHasTimestamp(stream identity.Stream) (pcommon.Timestamp, bool) { | ||
mt.RLock() | ||
defer mt.RUnlock() | ||
ts, ok := mt.lastTs[stream] | ||
return ts, ok | ||
} | ||
|
||
func (mt *MetricsTranslator) updateLastTsForStream(stream identity.Stream, ts pcommon.Timestamp) { | ||
mt.Lock() | ||
defer mt.Unlock() | ||
mt.lastTs[stream] = ts | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
receiver/datadogreceiver/tags.go → ...tadogreceiver/internal/translator/tags.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
receiver/datadogreceiver/tags_test.go → ...receiver/internal/translator/tags_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.