Skip to content

Commit

Permalink
Backwards compatibility fix for teraslice (#1186)
Browse files Browse the repository at this point in the history
* bump: (patch) [email protected], [email protected]

* Bump @terascope/[email protected]

* add isPromAvailable catch
  • Loading branch information
sotojn authored May 24, 2024
1 parent 60ec04f commit 0cef02c
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 36 deletions.
2 changes: 1 addition & 1 deletion asset/asset.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "elasticsearch",
"version": "3.7.0"
"version": "3.7.1"
}
4 changes: 2 additions & 2 deletions asset/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "asset",
"displayName": "Asset",
"version": "3.7.0",
"version": "3.7.1",
"private": true,
"description": "",
"license": "MIT",
Expand All @@ -20,7 +20,7 @@
"@terascope/data-mate": "^0.56.2",
"@terascope/elasticsearch-api": "^3.20.2",
"@terascope/elasticsearch-asset-apis": "^0.12.0",
"@terascope/job-components": "^0.74.2",
"@terascope/job-components": "^0.75.0",
"@terascope/teraslice-state-storage": "^0.53.2",
"@terascope/utils": "^0.59.1",
"datemath-parser": "^1.0.6",
Expand Down
28 changes: 15 additions & 13 deletions asset/src/__lib/ReaderAPIFetcher.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Fetcher, DataEntity } from '@terascope/job-components';
import { Fetcher, DataEntity, isPromAvailable } from '@terascope/job-components';
import { DataFrame } from '@terascope/data-mate';
import { ElasticsearchReaderAPI, ReaderSlice } from '@terascope/elasticsearch-asset-apis';
import { ESDateConfig } from '../elasticsearch_reader/interfaces';
Expand All @@ -14,18 +14,20 @@ export class ReaderAPIFetcher extends Fetcher<ESDateConfig> {
await super.initialize();

const { context, api, opConfig } = this;
await this.context.apis.foundation.promMetrics.addGauge(
'elasticsearch_records_read',
'Number of records read from elasticsearch',
['op_name'],
async function collect() {
const recordsRead = api.getRecordsFetched();
const labels = {
op_name: opConfig._op,
...context.apis.foundation.promMetrics.getDefaultLabels()
};
this.set(labels, recordsRead);
});
if (isPromAvailable(context)) {
await this.context.apis.foundation.promMetrics.addGauge(
'elasticsearch_records_read',
'Number of records read from elasticsearch',
['op_name'],
async function collect() {
const recordsRead = api.getRecordsFetched();
const labels = {
op_name: opConfig._op,
...context.apis.foundation.promMetrics.getDefaultLabels()
};
this.set(labels, recordsRead);
});
}
}

async fetch(slice: ReaderSlice): Promise<DataEntity[] | DataFrame | Buffer> {
Expand Down
28 changes: 15 additions & 13 deletions asset/src/elasticsearch_bulk/processor.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BatchProcessor } from '@terascope/job-components';
import { BatchProcessor, isPromAvailable } from '@terascope/job-components';
import { DataEntity } from '@terascope/utils';
import { ElasticsearchBulkSender } from '@terascope/elasticsearch-asset-apis';
import { ElasticSenderAPI } from '../elasticsearch_sender_api/interfaces';
Expand All @@ -15,18 +15,20 @@ export default class ElasticsearchBulk extends BatchProcessor<ElasticsearchBulkC
this.client = await apiManager.create('bulkSender', this.opConfig);
// eslint-disable-next-line @typescript-eslint/no-this-alias
const self = this;
this.context.apis.foundation.promMetrics.addGauge(
'elasticsearch_records_written',
'Number of records written to elasticsearch',
['op_name'],
async function collect() {
const labels = {
op_name: self.opConfig._op,
...self.context.apis.foundation.promMetrics.getDefaultLabels()
};
this.set(labels, self.getRecordsWritten());
}
);
if (isPromAvailable(this.context)) {
this.context.apis.foundation.promMetrics.addGauge(
'elasticsearch_records_written',
'Number of records written to elasticsearch',
['op_name'],
async function collect() {
const labels = {
op_name: self.opConfig._op,
...self.context.apis.foundation.promMetrics.getDefaultLabels()
};
this.set(labels, self.getRecordsWritten());
}
);
}
}

async onBatch(data: DataEntity[]): Promise<DataEntity[]> {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "elasticsearch-assets",
"displayName": "Elasticsearch Assets",
"version": "3.7.0",
"version": "3.7.1",
"private": true,
"description": "bundle of processors for teraslice",
"homepage": "https://github.com/terascope/elasticsearch-assets#readme",
Expand Down Expand Up @@ -46,7 +46,7 @@
"@terascope/elasticsearch-api": "^3.20.2",
"@terascope/elasticsearch-asset-apis": "^0.12.0",
"@terascope/eslint-config": "^0.8.0",
"@terascope/job-components": "^0.74.2",
"@terascope/job-components": "^0.75.0",
"@terascope/scripts": "0.77.2",
"@terascope/teraslice-state-storage": "^0.53.2",
"@terascope/types": "^0.17.1",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -803,12 +803,12 @@
progress "^2.0.3"
yargs "^17.2.1"

"@terascope/job-components@^0.74.2":
version "0.74.2"
resolved "https://registry.yarnpkg.com/@terascope/job-components/-/job-components-0.74.2.tgz#de875f792644abf3324f74d98e6b7daa046d7fff"
integrity sha512-FEliIWkcK43Q+kiONkwutXgV/f9qQMGUjesmJq9IyqYswOd7ZHtlXCjBUziKqdUWZ01OZ3YDzFxeuufJoLflUg==
"@terascope/job-components@^0.75.0":
version "0.75.0"
resolved "https://registry.yarnpkg.com/@terascope/job-components/-/job-components-0.75.0.tgz#03739729d7d7aee722b6291418987084cf65aaa9"
integrity sha512-QbIAKfbjX5Wj8A/hZvjE0E8y9hvW9QecQIw6eMwTRneudx2OPQcissCCYNlxBpfP13dK/U85BIqOVFZRTh8KcA==
dependencies:
"@terascope/utils" "^0.59.1"
"@terascope/utils" "^0.59.2"
convict "^6.2.4"
convict-format-with-moment "^6.2.0"
convict-format-with-validator "^6.2.0"
Expand Down

0 comments on commit 0cef02c

Please sign in to comment.