[OnWeek][ObsUX] Add fields to hosts in synthtrace to improve data generation (#187147)

## Summary

After improving the synthtrace data creation for containers we were able
to add more specific tests for container view, the aim of this spacetime
is to add some improvements to hosts so we can in the future use
synthtrace for testing

### What was done

First I thought that adding `event.dataset` was needed to get the
metadata, or make the request work, as I did for containers, but in
containers was needed not because of the metadata query itself but the
integration check to know if we need to display k8s or docker metrics.
I simplified the scenarios and data generation in the tests, adding the
metadata fields we need in the synthtrace clients for host and docker
and k8s containers, the values of the metadata fields doesn't need to
change for different scenarios, so it's ok to have them set in the
client.
This commit is contained in:
Miriam 2024-07-03 11:01:11 +01:00 committed by GitHub
parent 988795d1ff
commit 7274f44e9c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 27 additions and 37 deletions

View file

@ -51,5 +51,13 @@ class DockerContainerMetrics extends Serializable<DockerContainerMetricsDocument
export function dockerContainer(id: string): DockerContainer {
return new DockerContainer({
'container.id': id,
'container.name': `container-${id}`,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'docker.container',
});
}

View file

@ -17,6 +17,10 @@ interface HostDocument extends Fields {
'metricset.name'?: string;
'event.module'?: string;
'service.name'?: string;
'host.ip'?: string;
'host.os.name'?: string;
'host.os.version'?: string;
'cloud.provider'?: string;
}
class Host extends Entity<HostDocument> {
@ -126,5 +130,9 @@ export function host(name: string): Host {
'agent.id': 'synthtrace',
'host.hostname': name,
'host.name': name,
'host.ip': '10.128.0.2',
'host.os.name': 'Linux',
'host.os.version': '4.19.76-linuxkit',
'cloud.provider': 'gcp',
});
}

View file

@ -47,5 +47,13 @@ export function k8sContainer(id: string, uid: string, nodeName: string): K8sCont
'container.id': id,
'kubernetes.pod.uid': uid,
'kubernetes.node.name': nodeName,
'container.name': `container-${id}`,
'container.runtime': 'containerd',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'kubernetes.container',
});
}

View file

@ -21,17 +21,7 @@ const scenario: Scenario<InfraDocument> = async (runOptions) => {
.fill(0)
.map((_, idx) => {
const id = generateShortId();
return infra.dockerContainer(id).defaults({
'container.name': `container-${idx}`,
'container.id': id,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'docker.container',
});
return infra.dockerContainer(id);
});
const containers = range

View file

@ -21,19 +21,7 @@ const scenario: Scenario<InfraDocument> = async (runOptions) => {
.fill(0)
.map((_, idx) => {
const id = generateShortId();
return infra.k8sContainer(id, `pod-${idx}`, `node-${idx}`).defaults({
'container.id': id,
'kubernetes.pod.uid': `pod-${idx}`,
'kubernetes.node.name': `node-${idx}`,
'container.name': `container-${idx}`,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'kubernetes.container',
});
return infra.k8sContainer(id, `pod-${idx}`, `node-${idx}`);
});
const containers = range

View file

@ -60,19 +60,7 @@ export function generateDockerContainersData({
const containers = Array(count)
.fill(0)
.map((_, idx) =>
infra.dockerContainer(`container-id-${idx}`).defaults({
'container.name': `container-id-${idx}`,
'container.id': `container-id-${idx}`,
'container.runtime': 'docker',
'container.image.name': 'image-1',
'host.name': 'host-1',
'cloud.instance.id': 'instance-1',
'cloud.image.id': 'image-1',
'cloud.provider': 'aws',
'event.dataset': 'docker.container',
})
);
.map((_, idx) => infra.dockerContainer(`container-id-${idx}`));
return range
.interval('30s')