Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wundergraph/apollo-to-cosmo-metrics

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wundergraph/apollo-to-cosmo-metrics

An apollo gateway plugin that exports schema usage metrics to cosmo

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

Apollo To Cosmo Metrics

npm version

Cosmo's schema usage plugin for Apollo Gateway was build for the reason of having ability to report usage metrics to Wundergraph's cosmo ecosystem that helps to track operation's usage together with underlying types, arguments its inputs that schema can define.

Plugin implements ApolloServerPlugin interface that collects usage during request execution. Collected metrics are being stored in a local queue and being flushed via rpc to cosmo metrics endpoint once in a while (10-20 seconds, depends on config)

Plugin's implementation is currently missing some functionality, here is the list:

  • Deduplication of type usage reports, all type reports coming always with count of 1
  • Recursive processing of operation inputs, inputs that come as object variables are being collected max to level of 2. In case where a variable has deeper structure (> 2) the implementation will not process it all
  • Enum inputs are not being reported
  • Operation errors are not being reported, only successful ones (with code 200)
  • Cosmo metrics client implementation uses static proto api definition (taken from here), it would be nice to make it dynamic, meaning having ability to pull always a newest proto file and generate new client based on that
  • No support for subscritions

However, plugin is stable and is able to report lots of standard schema usage, this version is used is production already, results can be seen in schema usage tab in cosmo studio.

Example Usage

import { ApolloGateway } from '@apollo/gateway';
import { ApolloServer } from '@apollo/server';
import { startStandaloneServer } from '@apollo/server/standalone';
import { cosmoReportPlugin, CosmoClient } from '@wundergraph/apollo-to-cosmo-metrics';

const gateway = new ApolloGateway({
  supergraphSdl: 'supergraph-url',
});

// Plugin definition
const cosmoReportPlugin = cosmoReportPlugin(
  new CosmoClient({
    endpointUrl: 'https://cosmo-metrics.wundergraph.com',
    routerToken: 'router-token',
  }),
);

const server = new ApolloServer({
  gateway,
  plugins: [cosmoReportPlugin],
});

startStandaloneServer(server);

Keywords

FAQs

Package last updated on 10 Dec 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc