-
Notifications
You must be signed in to change notification settings - Fork 0
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
modify code to make it extensive for logs #42
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright The OpenTelemetry Authors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package huaweicloudreceiver | ||
|
||
import ( | ||
"context" | ||
|
||
"go.opentelemetry.io/collector/consumer" | ||
"go.opentelemetry.io/collector/pdata/plog" | ||
"go.opentelemetry.io/collector/pdata/pmetric" | ||
"go.opentelemetry.io/collector/receiver" | ||
) | ||
|
||
type receiverProcessor interface { | ||
processReceivedData(ctx context.Context, data []byte) error | ||
} | ||
|
||
type metricsReceiver struct { | ||
consumer consumer.Metrics | ||
} | ||
|
||
func (r *metricsReceiver) processReceivedData(ctx context.Context, data []byte) error { | ||
unmarshaler := &pmetric.JSONUnmarshaler{} | ||
|
||
metrics, err := unmarshaler.UnmarshalMetrics(data) | ||
if err != nil { | ||
return err | ||
} | ||
return r.consumer.ConsumeMetrics(ctx, metrics) | ||
} | ||
|
||
func newHuaweiCloudMetricsReceiver(cfg *Config, metrics consumer.Metrics, settings receiver.Settings) *huaweiReceiver { | ||
return newHuaweiCloudReceiver(settings, Metrics, cfg, &metricsReceiver{consumer: metrics}) | ||
} | ||
|
||
type logsReceiver struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if keeping the same component, i think you could separate files, |
||
consumer consumer.Logs | ||
} | ||
|
||
func (r *logsReceiver) processReceivedData(ctx context.Context, data []byte) error { | ||
unmarshaler := &plog.JSONUnmarshaler{} | ||
|
||
logs, err := unmarshaler.UnmarshalLogs(data) | ||
if err != nil { | ||
return err | ||
} | ||
return r.consumer.ConsumeLogs(ctx, logs) | ||
} | ||
|
||
func newHuaweiCloudLogsReceiver(cfg *Config, logs consumer.Logs, settings receiver.Settings) *huaweiReceiver { | ||
return newHuaweiCloudReceiver(settings, Logs, cfg, &logsReceiver{consumer: logs}) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since LTS is effectively a different service, i think it makes more sense to keep separate components like
awscloudwatchlogsexporter
andawskinesisexporter
but, i'm open for discussion