generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 65
feat: [Java] EMF Exporter Implementation #1209
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
Open
liustve
wants to merge
19
commits into
main
Choose a base branch
from
emf-exporter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
bcf5eb2
initial implmentation
liustve f6ba80a
formatting
liustve 0b2c14c
Merge branch 'main' into emf-exporter
liustve cd1475d
add emf exporter to changelog
liustve 5276407
add emf exporter to changelog
liustve 3ec3aa5
merge main
liustve 7cd68df
modify message
liustve e6a5283
add further unit tests
liustve 8067773
Merge branch 'main' into emf-exporter
liustve b686dc1
refactoring + more unit tests for all exporters
liustve af3b570
Merge branch 'main' into emf-exporter
liustve 48e9453
add unit tests for configuring emf exporter in adot
liustve 0e3e77a
Merge branch 'main' into emf-exporter
liustve 48ecda1
Merge branch 'emf-exporter' of https://github.com/aws-observability/a…
liustve fcbd7a0
delete duplicate customizer test
liustve 746e989
add further emf + auto instrumentation unit tests and better java docs
liustve 4236220
move emf exporter files, removed need to set x-aws-metric-namespace h…
liustve b7d0506
update CHANGELOG.md
liustve 82e0b46
plug emf and compact console log exporter to lambda
liustve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
73 changes: 73 additions & 0 deletions
73
...azon/opentelemetry/javaagent/providers/exporter/aws/metrics/AwsCloudWatchEmfExporter.java
This file contains hidden or 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,73 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"). | ||
* You may not use this file except in compliance with the License. | ||
* A copy of the License is located at | ||
* | ||
* http://aws.amazon.com/apache2.0 | ||
* | ||
* or in the "license" file accompanying this file. This file is distributed | ||
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either | ||
* express or implied. See the License for the specific language governing | ||
* permissions and limitations under the License. | ||
*/ | ||
|
||
package software.amazon.opentelemetry.javaagent.providers.exporter.aws.metrics; | ||
|
||
import io.opentelemetry.sdk.common.CompletableResultCode; | ||
import java.util.logging.Logger; | ||
import software.amazon.awssdk.services.cloudwatchlogs.CloudWatchLogsClient; | ||
import software.amazon.opentelemetry.javaagent.providers.exporter.aws.metrics.common.BaseEmfExporter; | ||
import software.amazon.opentelemetry.javaagent.providers.exporter.aws.metrics.common.emitter.CloudWatchLogsClientEmitter; | ||
import software.amazon.opentelemetry.javaagent.providers.exporter.aws.metrics.common.emitter.LogEventEmitter; | ||
|
||
/** | ||
* EMF metrics exporter for sending data directly to CloudWatch Logs. | ||
* | ||
* <p>This exporter converts OTel metrics into CloudWatch EMF logs which are then sent to CloudWatch | ||
* Logs. CloudWatch Logs automatically extracts the metrics from the EMF logs. | ||
* | ||
* <p><a | ||
* href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Embedded_Metric_Format_Specification.html">...</a> | ||
*/ | ||
public class AwsCloudWatchEmfExporter extends BaseEmfExporter<CloudWatchLogsClient> { | ||
private static final Logger logger = Logger.getLogger(AwsCloudWatchEmfExporter.class.getName()); | ||
|
||
/** | ||
* Initialize the CloudWatch EMF exporter. | ||
* | ||
* @param namespace CloudWatch namespace for metrics (default: "default") | ||
* @param logGroupName CloudWatch log group name | ||
* @param logStreamName CloudWatch log stream name (auto-generated if null) | ||
* @param awsRegion AWS region | ||
*/ | ||
public AwsCloudWatchEmfExporter( | ||
String namespace, String logGroupName, String logStreamName, String awsRegion) { | ||
super(namespace, new CloudWatchLogsClientEmitter(logGroupName, logStreamName, awsRegion)); | ||
} | ||
|
||
/** | ||
* Initialize the CloudWatch EMF exporter with a custom emitter. | ||
* | ||
* @param namespace CloudWatch namespace for metrics | ||
* @param emitter Custom log emitter | ||
*/ | ||
public AwsCloudWatchEmfExporter(String namespace, LogEventEmitter<CloudWatchLogsClient> emitter) { | ||
super(namespace, emitter); | ||
} | ||
|
||
@Override | ||
public CompletableResultCode flush() { | ||
this.emitter.flushEvents(); | ||
logger.fine("AwsCloudWatchEmfExporter force flushes the buffered metrics"); | ||
return CompletableResultCode.ofSuccess(); | ||
} | ||
|
||
@Override | ||
public CompletableResultCode shutdown() { | ||
this.flush(); | ||
logger.fine("AwsCloudWatchEmfExporter shutdown called"); | ||
return CompletableResultCode.ofSuccess(); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Does customer have to set all 3 headers?
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.
It looks like from Python implementation they don't need
namespace
header:https://github.com/aws-observability/aws-otel-python-instrumentation/blob/main/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/aws_opentelemetry_configurator.py#L127
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.
Removed validation for namespace header.