Skip to content

Commit f0687bd

Browse files
fix/missing readme and private methods in logger
1 parent 26eb978 commit f0687bd

5 files changed

Lines changed: 195 additions & 9 deletions

File tree

.idea/workspace.xml

Lines changed: 4 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1-
# Traceo SDK for JVM
1+
# Traceo SDKs for Java
22

3-
## Readme in progress ...
3+
A set of SDKS for integration with the [Traceo Platform](https://github.com/traceo-dev/traceo).
4+
5+
# Platforms
6+
This repository contains all the SDKs needed for integration in Java projects. Detailed instructions for the SDK implementation process can be found in the individual README for each SDK.
7+
8+
- [`traceo-sdk/java`](https://github.com/traceo-dev/traceo-java/tree/master/traceo-sdk) - Java.
9+
- [`traceo-sdk/opentelemetry-java`](https://github.com/traceo-dev/traceo-java/tree/master/traceo-sdk-opentelemetry) - Open Telemetry for Java.
10+
11+
## Support
12+
Feel free to create Issues, Pull Request and Discussion. If you want to contact with the developer working on this package click [here](mailto:piotr.szewczyk.software@gmail.com).

traceo-sdk-core/src/main/java/com/traceo/sdk/logging/client/TraceoLogger.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static TraceoLogger createLogger(ClientOptions options, String name) {
4141
return new TraceoLogger(name);
4242
}
4343

44-
public void sendLogs() {
44+
private void sendLogs() {
4545
this.logsHandler.send();
4646
}
4747

@@ -65,7 +65,7 @@ public void warning(String message, Object... args) {
6565
logsHandler.process(TraceoLogLevel.WARN, message, args);
6666
}
6767

68-
public void shutdown() {
68+
private void shutdown() {
6969
logsHandler.send();
7070
scheduler.shutdown();
7171
}

traceo-sdk-opentelemetry/README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Traceo SDK for Node.js
2+
3+
Library for integration with the [Traceo Platform](https://github.com/traceo-dev/traceo).
4+
5+
The Traceo platform offers the ability to collect and visualize data from [OpenTelemetry](https://opentelemetry.io/). OpenTelemetry, also known as OTel for short, is a vendor-neutral open-source Observability framework for instrumenting, generating, collecting, and exporting telemetry data such as traces, metrics, logs. [Docs](https://opentelemetry.io/docs/).
6+
7+
### How Traceo use OTel instruments?
8+
By using custom metrics and spans exporters (logs in near future). After receiving data from Otel instruments, the data is successively sent to the Traceo platform, where it is aggregated and visualized.
9+
10+
### Installation
11+
To install this SDK add this package to your `pom.xml` like below:
12+
```java
13+
<dependency>
14+
<groupId>com.traceo.sdk</groupId>
15+
<artifactId>traceo-sdk-opentelemetry</artifactId>
16+
<version>1.0.0</version>
17+
</dependency>
18+
```
19+
20+
or to `build.gradle`
21+
22+
```java
23+
dependencies {
24+
implementation 'com.traceo.sdk:traceo-sdk-opentelemetry:1.0.0'
25+
}
26+
```
27+
28+
**TIP:** Remember to init [`TraceoClient`]() before using this package.
29+
30+
### Metrics
31+
To use the exporter for metrics you need to use `TraceoMetricsExporter` like below:
32+
```java
33+
import com.traceo.sdk.TraceoMetricsExporter;
34+
import io.opentelemetry.api.metrics.MeterProvider;
35+
import io.opentelemetry.sdk.metrics.export.MetricReader;
36+
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReader;
37+
import io.opentelemetry.sdk.metrics.export.PeriodicMetricReaderBuilder;
38+
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
39+
import io.opentelemetry.sdk.resources.Resource;
40+
41+
PeriodicMetricReaderBuilder readerBuilder = PeriodicMetricReader
42+
.builder(new TraceoMetricsExporter()) //use traceo exporter here
43+
.setInterval(Duration.ofMillis(500)); //optional
44+
45+
MetricReader reader = readerBuilder.build();
46+
47+
MeterProvider meterProvider = SdkMeterProvider.builder()
48+
.setResource(Resource.getDefault())
49+
.registerMetricReader(reader)
50+
.build();
51+
52+
// use meterProvider to collect metrics
53+
```
54+
55+
After using `TraceoMetricsExporter` Traceo Platform will receive every metrics payload from OpenTelemetry.
56+
57+
### Spans
58+
To use the exporter for spans you need to use `TraceoSpansExporter` like below:
59+
```java
60+
import com.traceo.sdk.TraceoSpansExporter;
61+
import io.opentelemetry.sdk.trace.SdkTracerProvider;
62+
import io.opentelemetry.sdk.trace.export.BatchSpanProcessor;
63+
import io.opentelemetry.api.trace.Tracer;
64+
import io.opentelemetry.sdk.OpenTelemetrySdk;
65+
66+
SdkTracerProvider tracerProvider = SdkTracerProvider.builder()
67+
.addSpanProcessor(
68+
BatchSpanProcessor
69+
.builder(new TraceoSpansExporter())
70+
.build()
71+
)
72+
.build();
73+
74+
OpenTelemetrySdk openTelemetry = OpenTelemetrySdk.builder()
75+
.setTracerProvider(tracerProvider)
76+
.build();
77+
78+
Tracer tracer = openTelemetry.getTracerProvider().get("your-instrumentation-name");
79+
80+
// use tracer to instrument spans
81+
```
82+
83+
After using `TraceoSpansExporter` Traceo Platform will receive every span payload from OpenTelemetry.
84+
85+
## Support
86+
Feel free to create Issues, Pull Request and Discussion. If you want to contact with the developer working on this package click [here](mailto:piotr.szewczyk.software@gmail.com).

traceo-sdk/README.md

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Traceo SDK for Java
2+
3+
Library for integration with the [Traceo Platform](https://github.com/traceo-dev/traceo).
4+
5+
### Installation
6+
To install this SDK add this package to your `pom.xml` like below:
7+
8+
```java
9+
<dependency>
10+
<groupId>com.traceo.sdk</groupId>
11+
<artifactId>traceo-sdk</artifactId>
12+
<version>1.0.0</version>
13+
</dependency>
14+
```
15+
16+
or to `build.gradle`
17+
18+
```java
19+
dependencies {
20+
implementation 'com.traceo.sdk:traceo-sdk:1.0.0'
21+
}
22+
```
23+
24+
### Usage
25+
To init SDK in your project use internal `TraceoClientBuilder` to create client configuration and pass configurations to static `init()` method from `TraceoClient` class.
26+
```java
27+
TraceoClientConfiguration clientConfiguration = TraceoClientBuilder
28+
.standard()
29+
.withApiKey("tr_408917b2-42fb-43d9-8602-861879c1a273")
30+
.withHost("http://localhost:3000")
31+
.build();
32+
33+
TraceoClient.init(clientConfiguration);
34+
```
35+
36+
Table of available options in `TraceoClientBuilder`:
37+
38+
| Method | Description | Default | Required |
39+
|:----------:|:-----------------------------------------------------------------------------------------------------------------------------------------------:|:-------:|:--------:|
40+
| withApiKey | Project api key generated in Traceo Platform | ||
41+
| withHost | Host on which Traceo Platform is running provided in format `[protocol]://[domain]:[port]` | ||
42+
| withDebug | Set to true if you want to check internal logs for SDK. | false ||
43+
| withEnabled | If false then client is not initialized. None of the captured exceptions, spans or metrics are send to Traceo Platform. | true ||
44+
| withCatchUncaughtException | Set to true if you want to catch every uncaught exception. | false ||
45+
| withPackages | List of packages where SDK is used. Based on this values, SDK can check wheter incoming exception is inside client code or in external library. | ||
46+
| withExportIntervalMs | Set custom value for export default metrics interval. | 5000 ||
47+
48+
### Incidents handling
49+
50+
Incidents are all the exceptions and other problems that occur in your application. After each exception occurs, the Traceo SDK catches the exception and sends it to the Traceo Platform. To catch an exception and send it to the Traceo platform, use the static `catchException()` method from the `TraceoClient` class.
51+
52+
```
53+
try {
54+
// your code
55+
} catch (ArrayIndexOutOfBoundsException exception) {
56+
TraceoClient.catchException(exception);
57+
}
58+
```
59+
60+
### Logger
61+
62+
The Traceo SDK can be used also as a logger. Each log is saved on the Traceo Platform, thanks to which it is possible to later easily access the recorded information. Logs are sent to Traceo in every 180 seconds.
63+
Example of using logger:
64+
```java
65+
public class HttpClient {
66+
public static final TraceoLogger LOGGER = TraceoClient.getLogger(HttpClient.class);
67+
68+
// your code
69+
70+
public void makeRequest() {
71+
// your code
72+
73+
LOGGER.log("OK.");
74+
}
75+
}
76+
```
77+
78+
Available logger methods:
79+
80+
| Method | Description |
81+
|:-------:|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------:|
82+
| log | [The INFO level designates informational messages that highlight the progress of the application at coarse-grained level.](https://www.slf4j.org/api/org/apache/log4j/Level.html#:~:text=INFO-,The%20INFO%20level%20designates%20informational%20messages%20that%20highlight%20the%20progress%20of%20the%20application%20at%20coarse%2Dgrained%20level.,-static%20Level) |
83+
| debug | [The DEBUG Level designates fine-grained informational events that are most useful to debug an application.](https://www.slf4j.org/api/org/apache/log4j/Level.html#:~:text=DEBUG-,The%20DEBUG%20Level%20designates%20fine%2Dgrained%20informational%20events%20that%20are%20most%20useful%20to%20debug%20an%20application.,-static%20Level) |
84+
| error | [The ERROR level designates error events that might still allow the application to continue running.](https://www.slf4j.org/api/org/apache/log4j/Level.html#:~:text=ERROR-,The%20ERROR%20level%20designates%20error%20events%20that%20might%20still%20allow%20the%20application%20to%20continue%20running.,-static%20Level) |
85+
| warning | [The WARN level designates potentially harmful situations.](https://www.slf4j.org/api/org/apache/log4j/Level.html#:~:text=WARN-,The%20WARN%20level%20designates%20potentially%20harmful%20situations.,-static%20int) |
86+
87+
**TIP:** Remember to init `TraceoClient` before using `TraceoLogger`.
88+
### More
89+
This package is also required to integration with `OpenTelemetry for Java`. Full implementation guide can be found [here]().
90+
91+
## Support
92+
Feel free to create Issues, Pull Request and Discussion. If you want to contact with the developer working on this package click [here](mailto:piotr.szewczyk.software@gmail.com).

0 commit comments

Comments
 (0)