Skip to content

[ENG-9703] Feature/add new es8 metrics#11672

Open
bodintsov wants to merge 3 commits intoCenterForOpenScience:feature/9691-osfmetrics-migrationfrom
bodintsov:feature/add-new-es8-metrics
Open

[ENG-9703] Feature/add new es8 metrics#11672
bodintsov wants to merge 3 commits intoCenterForOpenScience:feature/9691-osfmetrics-migrationfrom
bodintsov:feature/add-new-es8-metrics

Conversation

@bodintsov
Copy link
Copy Markdown
Contributor

Ticket

https://openscience.atlassian.net/browse/ENG-9703

Purpose

Add new es8 metrics

Changes

Added new es8 metrics

Side Effects

TBD

QE Notes

TBD

CE Notes

TBD

Documentation

TBD

Copy link
Copy Markdown
Contributor

@aaxelb aaxelb left a comment

Choose a reason for hiding this comment

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

a few points clarifying intent for these migration targets

also, mind importing (at least something from) this file in osf/metrics/__init__.py and adding one or two smoke-tests to verify the index(templat)es are usable?

Comment on lines +132 to +165
class BasePreprintMetrics(djelme.CountedUsageRecord):
'''
inherited fields:
platform_iri: str
database_iri: str
item_iri: str
sessionhour_id: str
within_iris: list[str]
'''
count: int
provider_id: str
user_id: str
preprint_id: str
version: str
path: str

class Index:
settings = {
'number_of_shards': 1,
'number_of_replicas': 1,
'refresh_interval': '1s',
}

class Meta:
abstract = True
source = djelme.MetaField(enabled=True)


class PreprintView(BasePreprintMetrics):
pass


class PreprintDownload(BasePreprintMetrics):
pass
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's get rid of the separate preprint metrics -- intending to use the migration as a chance to consolidate preprint views/downloads into the same OsfCountedUsageRecord used for views and downloads of other types of objects

pageview_info: PageviewInfo


class CountedAuthUsage(djelme.CountedUsageRecord):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

instead of copying this as-is, meant to consolidate into OsfCountedUsageRecord above -- some of the fields are now on the base djelme.CountedUsageRecord, except with less osf-specific names and IRIs instead of local ids:

  • provider_id => database_iri
  • surrounding_guids => within_iris
  • item_guid => item_iri (with additional osf-specific item_osfid for the "osf guid")
  • session_id => sessionhour_id (not actually a COUNTER term, but making clear it's different from various other "session ids" and is distinct per hour)

pass


class RegistriesModerationMetrics(djelme.CountedUsageRecord):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
class RegistriesModerationMetrics(djelme.CountedUsageRecord):
class RegistriesModerationMetrics(djelme.EventRecord):

(CountedUsageRecord is a subclass of EventRecord with additional fields specific to COUNTER that we don't need for this internal event)

# Cyclic reports


class StorageAddonUsage(djelme.CyclicRecord, cycle_timedepth=djelme.DAILY):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

each CyclicRecord should have CYCLE_TIMEDEPTH classvar instead of the cycle_timedepth init-subclass kwarg (my fault this changed in djelme)



class StorageAddonUsage(djelme.CyclicRecord, cycle_timedepth=djelme.DAILY):
usage_by_addon: UsageByStorageAddon
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
usage_by_addon: UsageByStorageAddon
usage_by_addon: list[UsageByStorageAddon]

elastic-dsl list[...] annotations equivalent to old multi=True

Comment on lines +66 to +69
# fields autofilled from the above (see `_autofill_fields`)
page_path: str
referer_domain: str
hour_of_day: str
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(prompted by the comment) ideally let's move logic from the signal-triggered _autofill_fields and friends into an __init__ on each relevant class

also, since these fields shouldn't be required by the constructor (esdsl might raise an error?), should add a default e.g. page_path: str = ''

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants