Skip to content

Commit

Permalink
Upgrade container.id code according to the new change of OTel Java au…
Browse files Browse the repository at this point in the history
…to-instrumentation (#32)
  • Loading branch information
Rui Liu authored May 22, 2024
1 parent 6f10c54 commit 9fdfac2
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 29 deletions.
4 changes: 2 additions & 2 deletions host/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.instana.dc"
version = "0.1.3"
version = "0.1.4"

repositories {
mavenCentral()
Expand All @@ -20,7 +20,7 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-exporter-sender-okhttp:1.34.1")
implementation("io.opentelemetry.semconv:opentelemetry-semconv:1.23.1-alpha")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.0-rc1")
implementation(files("libs/otel-dc-0.9.7.jar"))
implementation(files("libs/otel-dc-0.9.8.jar"))

testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion internal/otel-dc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.instana.dc"
version = "0.9.7"
version = "0.9.8"

repositories {
mavenCentral()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@

import static java.util.Optional.empty;

/**
* Utility for extracting the container ID from runtimes inside cgroup v2 containers.
*/
/** Utility for extracting the container ID from runtimes inside cgroup v2 containers. */
class CgroupV2ContainerIdExtractor {

private static final Logger logger =
Logger.getLogger(CgroupV2ContainerIdExtractor.class.getName());

static final Path V2_CGROUP_PATH = Paths.get("/proc/self/mountinfo");
private static final Pattern CONTAINER_ID_RE = Pattern.compile("^[0-9a-f]{64}$");
private static final Pattern CRI_CONTAINER_ID_RE = Pattern.compile("cri-containerd:[0-9a-f]{64}");
private static final Pattern CONTAINERD_CONTAINER_ID_RE =
Pattern.compile("cri-containerd:[0-9a-f]{64}");
private static final Pattern CRIO_CONTAINER_ID_RE = Pattern.compile("\\/crio-[0-9a-f]{64}");

private final ContainerResource.Filesystem filesystem;

Expand Down Expand Up @@ -56,20 +56,32 @@ Optional<String> extractContainerId() {

Optional<String> optCid =
fileAsList.stream()
.filter(line -> line.contains("/containers/"))
.flatMap(line -> Stream.of(line.split("/")))
.map(CONTAINER_ID_RE::matcher)
.filter(Matcher::matches)
.reduce((first, second) -> second)
.map(matcher -> matcher.group(0));
.filter(line -> line.contains("/crio-"))
.map(CRIO_CONTAINER_ID_RE::matcher)
.filter(Matcher::find)
.findFirst()
.map(matcher -> matcher.group(0).substring(6));
if (optCid.isPresent()) {
return optCid;
}

optCid =
fileAsList.stream()
.filter(line -> line.contains("cri-containerd:"))
.map(CONTAINERD_CONTAINER_ID_RE::matcher)
.filter(Matcher::find)
.findFirst()
.map(matcher -> matcher.group(0).substring(15));
if (optCid.isPresent()) {
return optCid;
}

return fileAsList.stream()
.filter(line -> line.contains("cri-containerd:"))
.map(CRI_CONTAINER_ID_RE::matcher)
.filter(Matcher::find)
.findFirst()
.map(matcher -> matcher.group(0).substring(15));
.filter(line -> line.contains("/containers/"))
.flatMap(line -> Stream.of(line.split("/")))
.map(CONTAINER_ID_RE::matcher)
.filter(Matcher::matches)
.reduce((first, second) -> second)
.map(matcher -> matcher.group(0));
}
}
}
4 changes: 2 additions & 2 deletions llm/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.instana.dc"
version = "1.0.0"
version = "1.0.1"
sourceCompatibility = 11
targetCompatibility = 11

Expand All @@ -27,7 +27,7 @@ dependencies {
implementation("com.google.protobuf:protobuf-java-util:3.23.4")
implementation("com.linecorp.armeria:armeria:1.27.3")
implementation("com.linecorp.armeria:armeria-grpc:1.27.3")
implementation(files("libs/otel-dc-0.9.7.jar"))
implementation(files("libs/otel-dc-0.9.8.jar"))

testImplementation("org.junit.jupiter:junit-jupiter-api:5.8.1")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1")
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions rdb/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.instana.dc"
version = "0.5.2"
version = "0.5.3"

repositories {
mavenCentral()
Expand All @@ -20,7 +20,7 @@ dependencies {
implementation("io.opentelemetry:opentelemetry-exporter-sender-okhttp:1.34.1")
implementation("io.opentelemetry.semconv:opentelemetry-semconv:1.23.1-alpha")
implementation("com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.16.0-rc1")
implementation(files("libs/otel-dc-0.9.7.jar"))
implementation(files("libs/otel-dc-0.9.8.jar"))
implementation(files("libs/ngdbc-2.4.64.jar"))
implementation("org.apache.commons:commons-dbcp2:2.11.0")

Expand Down
12 changes: 6 additions & 6 deletions rdb/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ instances:
#Data collector properties:
poll.interval: 30
callback.interval: 20
otel.backend.url: http://9.112.252.66:4317
otel.backend.url: http://localhost:4317
#otel.backend.using.http: true
#otel.backend.url: https://host.docker.internal:8991/v1/metrics
#otel.backend.url: http://9.112.252.66:4318
#otel.backend.url: http://localhost:4318/v1/metrics

#OTel properties:
otel.service.name: DamengDC1
otel.service.name: DamengDcA

- db.address: 9.46.118.22
db.port: 5236
Expand All @@ -31,10 +31,10 @@ instances:
#Data collector properties:
poll.interval: 30
callback.interval: 20
otel.backend.url: http://9.112.252.66:4317
otel.backend.url: http://localhost:4317
#otel.backend.using.http: true
#otel.backend.url: https://host.docker.internal:8991/v1/metrics
#otel.backend.url: http://9.112.252.66:4318
#otel.backend.url: http://localhost:8992/v1/metrics

#OTel properties:
otel.service.name: DamengDC2
otel.service.name: DamengDcB
Binary file not shown.

0 comments on commit 9fdfac2

Please sign in to comment.