Skip to content
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

[APM] adds telemetry to APM #25513

Merged
merged 4 commits into from
Nov 20, 2018
Merged

Conversation

ogupte
Copy link
Contributor

@ogupte ogupte commented Nov 11, 2018

Summary

Fixes #24142 & #23318 by adding telemetry to APM

Checklist

Use strikethroughs to remove checklist items you don't feel are applicable to this PR.

For maintainers

@ogupte ogupte self-assigned this Nov 11, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

)
} as ApmTelemetry
);
}
Copy link
Member

@sorenlouv sorenlouv Nov 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about this simplification?

  const validAgentNames = agentNames.filter(
    agentName => Object.values(AgentName).includes(agentName)
  );
  return {
    has_any_services: validAgentNames.length > 0,
    services_per_agent: _.countBy(validAgentNames)
  };

It's not 100% equivalent to yours though since it omits the zero values. Not sure if that's a deal-breaker.

} catch (err) {
return createApmTelementry();
}
return apmTelemetrySavedObject.attributes;
Copy link
Member

@sorenlouv sorenlouv Nov 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid the let like:

      const savedObjectsClient = getSavedObjectsClient(server);
      try {
        const apmTelemetrySavedObject = await savedObjectsClient.get(
          'apm-telemetry',
          APM_TELEMETRY_DOC_ID
        );
        return apmTelemetrySavedObject.attributes;
      } catch (err) {
        return createApmTelementry();
      }

Copy link
Member

@sorenlouv sorenlouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. How would I test this locally?

export function getSavedObjectsClient(server: Server): any {
const {
savedObjects: { SavedObjectsClient, getSavedObjectsRepository }
} = server;
Copy link
Member

@sorenlouv sorenlouv Nov 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I find this easier to read:

const { SavedObjectsClient, getSavedObjectsRepository } = server.savedObjects;

getSavedObjectsClient
} from './apm_telemetry';

interface KibanaHapiServer extends Server {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a TODO that this should come from the platform

createApmTelementry(
serviceBucketList.map(({ agent_name }) => agent_name as AgentName)
)
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe break it up for readability?

const apmTelemetry = createApmTelementry(serviceBucketList.map(({ agent_name }) => agent_name as AgentName))
storeApmTelemetry(server, apmTelemetry)

@ogupte ogupte force-pushed the apm-24142-telemetry-data branch from c142b35 to 348a8b6 Compare November 20, 2018 06:11
@ogupte
Copy link
Contributor Author

ogupte commented Nov 20, 2018

LGTM. How would I test this locally?

I tested it locally by running elasticsearch, apm-server, and a number of services locally and pointed kibana to local ES. Then i would navigate to the APM landing page which shows all running services. finally i would GET .kibana/doc/apm-telemetry:apm-telemetry to verify that the apm-telemetry document was created with the correct data. This object is what is sent to metric collection service without any modifications, so should be sufficient to verify.

@elasticmachine
Copy link
Contributor

💔 Build Failed

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@ogupte ogupte merged commit 682c50c into elastic:master Nov 20, 2018
ogupte added a commit to ogupte/kibana that referenced this pull request Nov 20, 2018
* [APM] adds telemetry to APM

* [APM] Code and readability improvements for APM Telemetry

* [APM] fixed failing tests for apm-telemetry and service routes

* [APM] fix lint issues for APM Telemetry
ogupte added a commit that referenced this pull request Nov 20, 2018
* [APM] adds telemetry to APM

* [APM] Code and readability improvements for APM Telemetry

* [APM] fixed failing tests for apm-telemetry and service routes

* [APM] fix lint issues for APM Telemetry
@pickypg pickypg added v7.0.0 Feature:Telemetry v6.6.0 non-issue Indicates to automation that a pull request should not appear in the release notes labels Dec 10, 2018
@walterra walterra mentioned this pull request Jan 22, 2019
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Telemetry non-issue Indicates to automation that a pull request should not appear in the release notes v6.6.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants