forked from apache/eventmesh
-
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.
[ISSUE apache#340]merge otel metric branch 2 develop (apache#494)
* [ISSUE apache#340]Integrate With OpenTelemetry for metrics in EventMesh (apache#467) * The Chinese in the notes is translated into English. * Translation improvement * Translation improvement * fix Chinese annotation on runtime module * Export metrics data with open telemetry and use Prometheus for visual observation * Export metrics data with open telemetry and use Prometheus for visual observation * Export metrics data with open telemetry and use Prometheus for visual observation * Export metrics data with open telemetry and use Prometheus for visual observation * Improper modification * Improper modification * improve * improve * improve * tcp metrics export * improve * improve * merge from otel branch * check lisence Co-authored-by: ZePeng Chen <84842773+Roc-00@users.noreply.github.com>
- Loading branch information
Showing
13 changed files
with
736 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# EventMesh Metrics (OpenTelemetry+Prometheus) | ||
|
||
## Introduction | ||
|
||
[EventMesh(incubating)](https://github.com/apache/incubator-eventmesh) is a dynamic cloud-native eventing infrastructure. | ||
|
||
## An overview of OpenTelemetry | ||
|
||
OpenTelemetry is a collection of tools, APIs, and SDKs. You can use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) for analysis in order to understand your software's performance and behavior. | ||
|
||
## An overview of Prometheus | ||
|
||
Power your metrics and alerting with a leading open-source monitoring solution. | ||
|
||
- Dimensional data | ||
- Powerful queries | ||
- Great visualization | ||
- Efficient storage | ||
- Simple operation | ||
- Precise alerting | ||
- Many client libraries | ||
- Many integrations | ||
|
||
## Requirements | ||
|
||
### Functional Requirements | ||
|
||
| Requirement ID | Requirement Description | Comments | | ||
| :------------- | ------------------------------------------------------------ | ------------- | | ||
| F-1 | EventMesh users should be able to observe HTTP metrics from Prometheus | Functionality | | ||
| F-2 | EventMesh users should be able to observe TCP metrics from Prometheus | Functionality | | ||
|
||
## Design Details | ||
|
||
use the meter instrument provided by OpenTelemetry to observe the metrics exist in EventMesh then export to Prometheus. | ||
|
||
1、Initialize a meter instrument | ||
|
||
2、set the Prometheus server | ||
|
||
3、different metrics observer built | ||
|
||
## Appendix | ||
|
||
#### References | ||
|
||
https://github.com/open-telemetry/docs-cn/blob/main/QUICKSTART.md#%E5%88%9B%E5%BB%BA%E5%9F%BA%E7%A1%80Span |
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
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,46 @@ | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one or more | ||
# contributor license agreements. See the NOTICE file distributed with | ||
# this work for additional information regarding copyright ownership. | ||
# The ASF licenses this file to You under the Apache License, Version 2.0 | ||
# (the "License"); you may not use this file except in compliance with | ||
# the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License 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. | ||
# | ||
global: | ||
scrape_interval: 15s | ||
scrape_timeout: 10s | ||
evaluation_interval: 15s | ||
alerting: | ||
alertmanagers: | ||
- static_configs: | ||
- targets: [] | ||
scheme: http | ||
timeout: 10s | ||
api_version: v1 | ||
scrape_configs: | ||
- job_name: prometheus | ||
honor_timestamps: true | ||
scrape_interval: 15s | ||
scrape_timeout: 10s | ||
metrics_path: /metrics | ||
scheme: http | ||
static_configs: | ||
- targets: | ||
- localhost:9090 | ||
- job_name: EventMesh_HTTP_export_test | ||
honor_timestamps: true | ||
scrape_interval: 15s | ||
scrape_timeout: 10s | ||
metrics_path: /metrics | ||
scheme: http | ||
static_configs: | ||
- targets: | ||
- 127.0.0.1:19090 |
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
68 changes: 68 additions & 0 deletions
68
...rg/apache/eventmesh/runtime/metrics/openTelemetry/OpenTelemetryExporterConfiguration.java
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,68 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License 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 org.apache.eventmesh.runtime.metrics.openTelemetry; | ||
|
||
import io.opentelemetry.api.metrics.MeterProvider; | ||
import io.opentelemetry.exporter.prometheus.PrometheusCollector; | ||
import io.opentelemetry.sdk.metrics.SdkMeterProvider; | ||
import io.prometheus.client.exporter.HTTPServer; | ||
import org.apache.eventmesh.common.config.CommonConfiguration; | ||
import org.apache.eventmesh.runtime.configuration.EventMeshHTTPConfiguration; | ||
|
||
import java.io.IOException; | ||
|
||
//ues openTelemetry to export metrics data | ||
public class OpenTelemetryExporterConfiguration { | ||
|
||
private static HTTPServer server;//Prometheus server | ||
|
||
static int prometheusPort;//the endpoint to export metrics | ||
|
||
static MeterProvider meterProvider; | ||
/** | ||
* Initializes the Meter SDK and configures the prometheus collector with all default settings. | ||
* | ||
* @return A MeterProvider for use in instrumentation. | ||
*/ | ||
public MeterProvider initializeOpenTelemetry(CommonConfiguration configuration) { | ||
if (server!=null){//the sever already start | ||
return meterProvider; | ||
} | ||
|
||
prometheusPort = configuration.eventMeshPrometheusPort; | ||
SdkMeterProvider sdkMeterProvider = SdkMeterProvider.builder().buildAndRegisterGlobal(); | ||
PrometheusCollector.builder().setMetricProducer(sdkMeterProvider).buildAndRegister(); | ||
this.meterProvider = sdkMeterProvider; | ||
try { | ||
server = new HTTPServer(prometheusPort,true);//Use the daemon thread to start an HTTP server to serve the default Prometheus registry. | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
return meterProvider; | ||
} | ||
|
||
public static MeterProvider getMeterProvider(){//for tcp or http to get the initialized meterProvider | ||
return meterProvider; | ||
} | ||
|
||
public void shutdownPrometheusEndpoint() { | ||
if (server==null) | ||
return; | ||
server.stop(); | ||
} | ||
} |
Oops, something went wrong.